html - 这些编码风格是否正确?

标签 html css

<分区>


想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它.

关闭 7 年前

我刚开始学习 CSS,并在我的本地门户网站上创建了一个示例页面。我想知道这些编码风格是否正确。

我开始知道这些编码风格在很大程度上不起作用。

您能否根据我的代码更正我的代码使其更加可行,我会尝试学习您的一些编码风格并根据我的需要进行调整。

很抱歉,如果此类问题无法在此站点中提出。

<div class="initial">

<div style="position:relative; width:100%; margin-Top: 4.75%; font-size: 1.3em; font-family: Helvetica; text-align: center; background-color: #bbb;">
<center><p style='line-height:200%'>

<a href=h.php style="text-decoration: none; color:white"> Home</a>	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
<a href=click.php style="text-decoration: none; color:white">Please Click Here</a>	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
<a href=contact.php style="text-decoration: none; color:white">Contact</a>	&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<a href=about.php style="text-decoration: none; color:white">About Me</a></p></center>
    
</style>
</div>
</div>

谢谢,

最佳答案

首先要注意的几点..

  1. 不要使用内联 CSS
  2. 不要使用  ,而是使用 marginpadding
  3. margin 和 padding 让你在两个标签之间留出空间

查看我如何实现 padding

的片段

.initial-content {
  position: relative;
  width: 100%;
  margin-Top: 4.75%;
  font-size: 1.3em;
  font-family: Helvetica;
  text-align: center;
  background-color: #bbb;
}
p {
  line-height: 200%;
}
a {
  text-decoration: none;
  color: white;
  padding: 5px 25px;
}
<div class="initial">

  <div class="initial-content">
    <center>
      <p>

        <a href=h.php> Home</a>
        <a href=click.php>Please Click Here</a>
        <a href=contact.php>Contact</a>
        <a href=about.php>About Me</a>
      </p>
    </center>

  </div>
</div>

关于html - 这些编码风格是否正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32780895/

上一篇:jquery - 我使用 div 添加了背景图像

下一篇:javascript - 如何显示/隐藏带有 <?php?> 的 <div>

相关文章:

html - 跨度彼此相邻

css-float - 为什么左边距会跳起来?

asp.net - 使用 CSS 的 Visual Studio 设计 View

javascript - 如何知道字体(@font-face)是否已经加载?

css - HTML 5,类的使用

iphone - 在 iPhone HTML 邮件中显示本地镜像

html - 我可以在 Twitter 的官方小部件上强制使用窄布局吗?

javascript - 一旦达到条件就停止

html - 响应图像 - 额外填充?

javascript - 在JavaScript中播放特定时间的音频