首页 > 解决方案 > 样式标题:从 W3.CSS 中删除边距

问题描述

.main_header 
{ 
  background: tomato;
  height: 250px;
  width:100%;
  margin:0 !important;
  padding:0 !important;
  
}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

 <div style="padding:0 !important; margin:0 !important;" class="w3-container w3-red">
        <p>test</p>    
  </div>
  
   <div class ="main_header">
   <p> test_2</p>
   </div>

在尝试在 a 的中间添加一个带 definedpage.aspx的部分时,我使用了 2 种方法:headerbackground-color

1.:

a - 在母版页中添加:

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">

b- 在目标中使用page.aspx:

<div style="padding:0 !important; margin:0 !important;" class="w3-container w3-red">
            <p>test</p>
        </div>

2.:

c - 在母版页中定义:

<style type="text/css">

....

.main_header 
{ 
  background: tomato;
  height: 250px;
  width:100%;
  margin:0 !important;
  padding:0 !important; 
}
</style>

d- 然后在目标中使用page.aspx

<div class ="main_header"></div>

==> 两种方法(1 和 2)产生相同的结果:条形/标题部分出现在页面的中心。但是,我希望两者都left/right-margins被删除,以便使栏/标题部分显示在整个网页上,就像fixed Navbar.

注意:请注意,申请style sheet没有帮助:

html, body{
  margin:0 !important;
  padding:0 !important;
}

因此,任何解释/想法都将受到高度赞赏。

标签: htmlcssasp.netheader

解决方案


推荐阅读