html - 带有 CSS 的 div 上不需要的边距

标签 html css dreamweaver

我正在尝试使用 Dreamweaver 和 CSS 格式化网站,但在“左侧”div 上出现不需要的边距,该 div 的长度与容器的长度相同:

<div class="cover"> 
<div class="Header">
  <div class="header_left"><input name="searchbar" type="text" class="header_searchbar" value="Search" maxlength="50">
    <a href="#"><img src="image/search.jpg" width="122" height="344" align="baseline" class="header_search_icon"></a></div>
  <div class="header_center"> <a href="index.html"><img src="image/logo.jpg" width="194" height="81" hspace="53" class="logo"></a></div>
    <div class="header_right">
      <div class="header_right_login"><a href="#">Sign In</a></div>
      <a href="#"><img src="image/lock.jpg" width="11" height="16"></a>
      <div class="header_right_language"> 
        <p><a href="#">Languages</a></p>
    </div>
      </div>  
  </div>

  <div class="Content">
    <div id="hot_bar">
      <div id="left"> <img src="image/left.jpg" alt="" width="33" height="65"></div>
      <div id="center"> content placeholder</div>
    </div>
  </div>

  <div class="footer">
    <ul>
      <li><a href="#">About </a></li>
      <li2>/</li2>
      <li><a href="#">Family</a></li>
      <li2>/</li2>
      <li><a href="#">Privacy Policy</a></li>
      <li2>/</li2>
      <li><a href="#">Terms of Service</a></li>
      <li2>/</li2>
    <li><a href="#">Help</a></li>
    <li2>/</li2>
    <li><a href="#">Contact Us</a></li>
  </ul>
</div>
</div>

CSS:

#left {
height: 298px;
width: 54px;
margin: 0px;
padding: 0px;
clear: left;
}
.cover .Content #hot_bar #left img {
margin-top: 125.5px;

}
#center {
height: 298px;
width: 724px;
margin-left: 0px;
float: none;
}
#right {
margin: 0px;
padding: 0px;
clear: right;
height: 298px;
width: 98px;
}
.right {
margin: 0px;
padding: 0px;
clear: right;
height: 298px;
width: 98px;
}
div {
width: 150px;
}
body {
margin: 0px;
padding: 0px;
}

编辑:在 Chrome 的检查元素中看起来像这样: enter image description here

中文部分是内容占位符。内容部分如下所示:

enter image description here

对不起,格式不好。我对此很陌生。

最佳答案

您应该更改 css 顺序。 body ,div,......,left,... 并添加 !important。里面#left

   /* !important is an optional . */
   #left {
   height: 298px;
   width: 54px;
   margin-left: 0px !important;
   padding-left: 0px !important;
   left:0 !important;
   top:0 !important;
   clear: left;
   }


   .content,#hot_bar{
    margin-left: 0px ;
    padding: 0px 0px;
    clear: left;
    left:0 !important;    
    }

fiddle

关于html - 带有 CSS 的 div 上不需要的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24113089/

相关文章:

php - 如何在 Dreamweaver 或 Notepad++ 中创建宏/快捷方式

javascript - html 中真的需要 name 属性吗?

html - 将渐变背景颜色设置为整个侧边菜单

css - background-size : cover; and background-size: 100%;?有什么区别

CSS 图像未显示在页面上

javascript - Dreamweaver 不断将外部 CSS 文件与本地服务器上的本地 CSS 一起拉取

html - CSS/模板问题

php - 搜索栏失效

html - 将按钮与带有标签的输入表单对齐

php - 在 Yii2 中覆盖 Bootstrap CSS