右側固定,左側自適應佈局(1)

HTML代碼:html

<div class="content">
	<ul>
		<li>
			<a href="#">
                  <!--文章標題及摘要位於左側--> <div class="fl news_txt"> <div class="hdline ft16 pad_btm10">中俄將簽定一攬子合做協議 </div> <p>應俄羅斯總理梅德韋傑夫邀請,應俄羅斯理梅德韋傑夫邀請,應俄羅斯總理梅德韋傑夫邀請2222</p> </div>
                   <!--文章圖片位於右側-->
                   <div class="fr news_img"><img src="http://minimg.hexun.com/i8.hexunimg.cn/2014-08-21/167741125_c166x118.jpg" width="100" height="70" alt="圖片" class="newsimg"/></div> </a> </li> </ul> </div>

 全局聲明CSS代碼:佈局

html{font-size:62.5%;}
body{min-width:320px;width:100%;font-size:1.2rem;;font-family:'微軟雅黑';color:#333;background:#fff;}
div,p,a,ul,li,p,dl,dt,dd,h1,h2,h3,body{margin:0;padding:0;}
ul,li{list-style:none;}
a{text-decoration:none;}
header,nav,article,footer{display:block;}
img{border:0;}
.fl{float:left;}
.fr{float:right;}
.ft12{font-size:1.2rem;}
.ft14{font-size:1.4rem;}
.ft16{font-size:1.6rem;}
.pad_btm10{padding-bottom:10px;}

 方法一(右側margin-left:-100%):spa

/*頁面佈局樣式*/
.content{width:100%;overflow:hidden;}
.content li{padding:10px;border-bottom:1px solid #ccc;overflow:hidden;}
.content li a{color:#333;display:block;}
.news_txt{margin-right:110px;}/*左側部分*/
.news_txt p{line-height:1.4;max-height:2.8em;overflow:hidden;color:#666;}
.news_img{margin-left:-100%;width:100px;}/*右側部分*/

方法二(定位position):code

.content{width:100%;overflow:hidden;}
.content li{min-height:70px;padding:10px;border-bottom:1px solid #ccc;overflow:hidden;position:relative;}/*對li進行position*/
.content li a{color:#333;display:block;}
.news_txt{margin-right:110px;}
.news_txt p{line-height:1.4;max-height:2.8em;overflow:hidden;color:#666;}
.news_img{width:100px;position:absolute;top:10px;right:10px;}/*右側絕對定位*/
相關文章
相關標籤/搜索