你知道如何强制将我的H1文本放在蓝色类别按钮下面吗?目前它紧挨着它。非常感谢
<div id="article" class="animated2 fadeInLeftBig">
<div class="article-close"></div>
<div class="category">#Category</div>
<h1>This is the H1</h1>
<p class="intro">Lorem ips um dolor sit amet, consectetur adipiscing elit. Nam sit amet diam nisl. Aliquam quis est eu elit facilisis aliquam. Pellentesque porta nunc diam <a class="various" href="#">Inline</a></p>
</div>
CSS:
#article {
/* opacity controlled via fadeInLeftBig */
position: absolute;
width: 600px;
left: 230px;
top: 0;
height:100%;
background-color: #fff;
opacity:0.9;
padding: 30px 50px 50px 50px;
z-index: 1000;
box-shadow:-2px 0 5px 0 rgba(0, 0, 0, 0.5);
}
#article .intro{
font-family: 'Open Sans', sans-serif;
font-weight:600;
}
#article h1 {
font-size: 33px;
color:#555;
font-style:italic;
}
#article h2 {
color:#555;
margin-bottom:5px;
}
#article p {
font-style: normal;
font-weight: 300;
/* color: #555; */
color: #555;
font-size: 15px;
line-height: 22px;
padding: 10px 0;
margin-top: -10px;
text-align:justify;
}
#article a {
color: #F15034;
text-decoration: none;
font-weight: bold;
}
#article a:hover {
border-bottom: 2px solid #F15034;
}
.category {
float: left;
text-align: center;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
background: rgba(71, 186, 255, 0.8);
}
答案 0 :(得分:1)
您应该在h1标签上clear: both;
。另一种方法是创建clear:both;
<div>
,但在此实例中不需要。
DEMO:http://jsfiddle.net/TDBzN/6/;
h1
{
clear:both;
}
要创建clear:both;
div
,请将其放在h1
元素和浮动元素之间,在这种情况下为.category
。
<div style="clear: both;"></div>
这有助于插入需要清除元素的位置,并且不适合直接清除元素。
答案 1 :(得分:0)
在你的标题上留下清楚的左侧
#article h1 {
font-size: 33px;
color:#555;
font-style:italic;
clear:left;
}
答案 2 :(得分:0)
<强> DEMO 强>
从以下位置编辑类.category:
.category {
float: left; /* REMOVE */
text-align: center;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
background: rgba(71, 186, 255, 0.8);
}
要
.category {
max-width:70px; /* EDITED */
text-align: center;
font-size: 12px;
color: white;
padding: 8px 18px;
margin: 18px 0 0 0px;
text-decoration: none;
-webkit-transition: background 0.3s ease;
-moz-transition: background 0.3s ease;
-ms-transition: background 0.3s ease;
-o-transition: background 0.3s ease;
transition: background 0.3s ease;
background: rgba(71, 186, 255, 0.8);
}
它工作正常。