我有一个节有两个新闻文章的HTML是正确的,但CSS的结果是第二个文章是第一个以上。任何建议表示感谢提前感谢。CSS的问题放在第一个以上的第二个元素
下面是结果的图像:
我的jsfiddle: http://jsfiddle.net/mibb/5sype/2/
我的HTML:
<section id="loop-news-container">
<h2>NEws</h2>
<article id="loop-news">
<a href="#"></a>
<h1><a href="#">Title of News</a></h1>
<span>Date of Post 1</span>
<img src="image1.jpg" />
<p>Post 1. <a href="#" >read more</a></p>
</article>
<article id="loop-news">
<a href="#"></a>
<h1><a href="#">Title 2 Inside of the Post 1</a></h1>
<span>Date 2 inside of Post 1</span>
<img src="image1.jpg" />
<p>Post 2 inside of Post 1<a href="#" >read more</a></p>
</article>
</section>
个我的CSS:
#loop-news-container {
width:100%;
height:auto;
float:left;
margin-top:5px;
}
#loop-news {
width:320px;
height:250px;
background:#fff;
margin-top:10px;
margin-bottom:10px;
text-align:center;
border-bottom:1px solid #f3f3f3;
}
#loop-news-container h2{font-family:'arial';
font-size:25px;
margin-bottom:10px;
font-weight:100;
color:green;
text-align:center;}
#loop-news h1 {
font-family:'arial';
text-align:center;
font-family:'arial';
margin:0 auto 0 auto;
position:relative;
text-decoration:none;
}
#loop-news p {font-family:'arial';
font-size: 17px;
text-align:justify;
line-height:25px;
height:25px;
width:310px;
margin:0 auto;
}
#loop-news h1 a {
text-decoration:none;
font-size:20px;
color:yellow;
font-weight:100;
font-family:'arial';
}
#loop-news span {
font-family:'bariolthin';
font-size:14px;
font-weight:normal;
color:blue;
margin:0 auto 0 auto;
text-align:center;
}
#loop-news a {font-family:'arial';
font-size:14px;
text-decoration:none;
color:red;
margin-left:2px;}
#loop-news img {margin-top:5px;margin-bottom:5px; width:246px;}
你有两个具有相同ID的元素会建议使用类来代替。我不确定这是否只是一个想法而引起你的问题。 – vikingben
感谢您的提示..但它不是主要问题! – OzzC