• 右侧固定,左侧自适应布局(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;}/*右侧绝对定位*/
  • 相关阅读:
    Python 更新pip报错:Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问
    Vs code 配置(1)-win10
    博客园主题--sukura
    log4j
    安装ant问题
    freemarker string= null
    学习随想
    j2ee学习资料收集
    eclipse + marven
    好文mark
  • 原文地址:https://www.cnblogs.com/0808bing/p/4036764.html
Copyright © 2020-2023  润新知