讨论题


定宽+自适应宽

/*方法一:弹性布局*/

.parent1{

display: flex;

height:300px;

}

.side1{

width:200px;

height:100%;

background-color:#c00000;

margin-right:10px;

}

.main1{

flex:1;

background-color:#4f81bd;

}

/*方法二:浮动*/

.side2{

width:200px;

height:300px;

background-color:#c00000;

float:left;

}

.main2{

height:300px;

margin-left:210px;

background-color:#4f81bd;

}

/*方法三:绝对定位*/

.parent3{

height:300px;

position:relative;

}

.side3{

width:200px;

height:100%;

background-color:#c00000;

}

.main3{

position:absolute;

height:100%;

width:100%;

left:210px;

top:0;

background-color:#4f81bd;

}


<div class="tab">

    <ul class="lesson">

        <li class="active">课程</li>

        <li>学习计划</li>

        <li>技能图谱</li>

    </ul>

    <div class="con">

        <p class="con_1">课程内容</p>

        <p class="con_2">学习计划内容</p>

        <p class="con_3">技能图谱内容</p>

    </div>

</div>

弹性布局

body{ margin: 0; }

li{ list-style: none; }

ul, p{ padding: 0; margin: 0; }

/* css reset */

body{ font-size: 14px; font-family: '微软雅黑'; }

.tab{ width: 572px; border: 1px solid #999; margin: 10px auto; }

.lesson{ display: flex; }

li{ flex-grow: 1; flex-basis: 0; text-align: center; border-left: 1px solid #cecece; border-bottom: 1px solid #cecece;

line-height: 30px;background: #f1f1f1; }

.con{ height: 40px; background: #fff; padding: 20px; }

.con_1, .con_2, .con_3{ display: none; }

.con_1{ display: block; }

.active{ background: #ffffff; border: none; }

一般版本--兼容IE6

body{ font-size: 14px; font-family: '微软雅黑'; }

ul, p{

margin: 0;

padding: 0;

}

li {

list-style: none;

}

/* css reset */

.clear { zoom: 1 }

.clear:after { content: ''; display: block; clear: both  }

.tab {

margin: 10px auto;

width: 572px;

border: 1px solid #999;

}

.lesson li {

float: left;

width: 190px;

line-height: 30px;

text-align: center;

border: 1px solid #cecece;

border-top: none;

border-right: none;

background: #f1f1f1;

}

.lesson .active { border: 0; background: #ffffff; }

.con{ height: 40px; background: #fff; padding: 20px; }

.con_1, .con_2, .con_3{ display: none; }

.con_1{ display: block; }

.active{ background: #ffffff; border: none; }


<div class="pop">

    <div class="head">

        <p class="title">标题栏</p>

        <button class="close></button>

</div>

    <div class="content">

        <p class="text">内容区段落</p>

        <buttonclass="button">确定</button>

    </div>

</div>

/*整个弹出窗口设置,弹性布局*/

.pop{

position: fixed;

top: 50%;

right: 50%;

transform: translate(50%, -50%);

width: 300px;

border: 1px solid #cccccc;

border-radius: 5px;

}

/*head作为关闭按钮的参考物*/

.head{

position: relative;

height: 40px;

background-color: #eeeeee;

}

/*设置行高和元素同高来使文字居中,分别设置隐藏、不换行和...*/

.title{

height: 100%;

margin: 0 20px;

font: 14px/40px "微软雅黑";

overflow: hidden;

white-space: nowrap;

text-overflow: ellipsis;

}

/*考虑到关闭按钮位置已确定,采用绝对定位,去除按钮默认边框,以背景图方式引入图片,失败则用红色标记*/

.close{

position: absolute;

border: 0;

padding: 0;

top: 10px;

right: 10px;

width: 10px;

height: 10px;

background: url('../x.png') red;

cursor: pointer;

}

/*把段落和按钮都放入内容区padding内*/

.content{

padding: 20px;

background-color: white;

font: 12px/1.5 "宋体";

}

/*段落距按钮20px*/

.text{

margin: 0 0 20px 0;

}

/*左右margin为auto使按钮居中,前提是button设为块级;去除按钮默认边框*/

.button{

display: block;

margin: 0 auto;

padding: 0;

width: 80px;

height: 30px;

border: none;

border-radius: 5px;

background-color: blue;

color: white;

text-align: center;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 不会用代码框,所以看着有些乱套,,,,html部分 <!DOCTYPE html> 迅雷看看 ...
    这就是个帅气的名字阅读 1,961评论 0 0
  • 深入理解傅里叶变换Mar 12, 2017 这原本是我在知乎上对傅立叶变换、拉普拉斯变换、Z变换的联系?为什么要进...
    价值趋势技术派阅读 5,975评论 2 2
  • 1、垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,...
    kiddings阅读 3,329评论 0 11
  • 静态代码块:随着类的加载而被执行,只执行一次,优先于main函数和其他函数的执行,可以用于类的初始化 样式:sta...
    Jonath阅读 164评论 0 0
  • 看到验孕棒上的两道杠,我有些不敢相信,细细看,有一道略浅些,这种情况是以前从未有过的。我拿着它到房间里,给还在床上...
    na0na0阅读 526评论 0 0

友情链接更多精彩内容