zoukankan      html  css  js  c++  java
  • 右侧固定,左侧自适应布局(1)

    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%):

    /*页面布局样式*/
    .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):

    .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;}/*右侧绝对定位*/
  • 相关阅读:
    关闭编辑easyui datagrid table
    sql 保留两位小数+四舍五入
    easyui DataGrid 工具类之 util js
    easyui DataGrid 工具类之 后台生成列
    easyui DataGrid 工具类之 WorkbookUtil class
    easyui DataGrid 工具类之 TableUtil class
    easyui DataGrid 工具类之 Utils class
    easyui DataGrid 工具类之 列属性class
    oracle 卸载
    “云时代架构”经典文章阅读感想七
  • 原文地址:https://www.cnblogs.com/0808bing/p/4036764.html
Copyright © 2011-2022 走看看