0

你知道如何强制将我的 H1 文本放在蓝色类别按钮下方吗?目前它就在它旁边。非常感谢

http://jsfiddle.net/TDBzN/

在此处输入图像描述

<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);
}
4

3 回答 3

1

你应该clear: both;在 h1 标签上。另一种方法是创建一个clear:both; <div>,但在这种情况下不需要这样做。

演示:http: //jsfiddle.net/TDBzN/6/

h1 
{
    clear:both;
}

要创建一个clear:both; div将 this 放在h1元素和浮动元素之间,在本例中为.category.

<div style="clear: both;"></div>

这仅有助于在需要清除元素的位置插入,并且不适合直接清除元素。

于 2013-06-22T16:55:40.930 回答
0

演示

从以下位置编辑类 .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);
}

它工作正常。

于 2013-06-22T17:18:27.680 回答
0

清楚地离开你的标题应该工作

#article h1 {
    font-size: 33px;
    color:#555;
    font-style:italic;
    clear:left;
}

http://jsfiddle.net/TDBzN/2/

于 2013-06-22T16:49:20.033 回答