div三栏中间自适应布局

<!DOCTYPE html>

<html>

<body>
<div class="container">
	<div class="maincontainer" >
		<div class="main">main</div>
	</div>
		<div class="left">left</div>

		<div class="right">right</div>

</div>
</body>

</html>

<style>
div{
height:500px;

}
.container{
border:1px solid black;

}

.maincontainer{
float:left;
width:100%;

}

.main{
border:1px solid red;

margin-left:250px;
margin-right:250px;
}

.left{
border:1px solid yellow;
float:left;
width:200px;
margin-left:-100%;
}

.right{
border:1px solid pink;
float:left;
width:200px;
margin-left:-202px;
}
</style>



<div id="main">
<div id="mainContainer">main content</div>
</div>
<div id="left">
<div id="leftContainer" class="inner">left content</div>
</div>
<div id="right">
<div id="rightContainer" class="inner">right</div>
</div>
<style>
#main {
float: left;
width: 100%;
}
#mainContainer {
margin: 0 230px;
height: 200px;
background: green;
}
#left {
float: left;
margin-left: -100%;
width: 230px
}
        
#right {
float: left;
margin-left: -230px;
width: 230px;
}
        
#left .inner,
#right .inner {
background: orange;
margin: 0 10px;
height: 200px;
}
</style>


<html><head></head><body>
<div class="container">
<div class="left">left</div>
<div class="main">main</div>
<div class="right">right</div>


</div>








<style>
div{
height:500px;
}
.container{
border:1px solid black;
display:inline-block;
width: 100%;
}


.main{
border:1px solid red;
width: calc(100% - 400px);
display:inline-block;
}


.left{
border:1px solid yellow;
width:200px;
display:inline-block;
}


.right{
border:1px solid pink;
width:200px;
display:inline-block;
}
</style></body></html>




css3  新特性calc()



<div id="demo">
  <div id="a"></div>
  <div id="b"></div>
</div>

<style>
#demo {
    width: 100px;
    height: 100px;
    border: 2px solid #000;
    position: relative;
}
#demo:after {
    content: '';
    display: block;
    width: 14.1421px;
    height: 14.1421px;
    border-top: 2px solid #000;
    border-right: 2px solid #000;
    position: absolute;
    right: -10px;
    top: 20px;
    transform: rotate(45deg);
    background-color: #fff;
}
</style>

<script>

function solution(n){
	var x = 1;
	if(n>=this.x){
		console.log(x);
		setTimeout(function(){solution(--x);},1000);
	}
};
solution(5);

void function loop(i) {
    if (i <= 50) {
        console.log(i);
        setTimeout(function() {loop(++i);}, 1000);
    }
};

var a = {
	foo:1,
	methodA:function(){console.log(this.foo);}
};
var b = {
	bar:2,
	methodB:function(){console.log(this.bar);}
};
a.methodB =function(){
b.methodB.apply(b);
}
//请添加一些语句,使得
//执行a.methodA()输出1
//执行a.methodB()输出2
//执行b.bar = 3;a.methodB()输出3
</script>

<!DOCTYPE html>

<html>
<head>
	<meta charset="utf-8">
</head>
<body>
	<div id="head">
		<div id="logo"></div>
		<div id="username">用户名</div>
	</div>
	<div class="main" >
		<div class="main" style="float:left;width:100%;">	
			<div id="content"></div>
		</div>
		<div id="aside" ></div>
	</div>
	<div id="footer">footer</div>
</body>
</html>
<style>
div{
	border-style:solid;
	border-width:1px;
	margin-top:5px;
	margin-bottom:5px;
}

#head{
	border-color:green;
	height:50px;
}

#logo{
	border-color:red;
	width:40px;
	height:40px;
	margin-left:5px;
	margin-top:5px;
	margin-right:5px;
	float:left;
}

#username{
	border-color:black;
	width:100px;
	height:20px;
	float:right;
	margin-top:25px;
	margin-right:5px;
	
}

#content{
	border-color:blue;
	height:400px;
	margin-right:210px;
}

#aside{
	border-color:red;
	width:200px;
	height:20px;
	float:left;
	margin-left:-202px;
}

.main{
	border:none;
	margin:0px;
	height:410px;
}

#footer{
	border-color:black;
	text-align:center;
	height:20px;
}
</style>
</style>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: <div style="width:100%;"> <div style="float:left;width:30%;">左栏内容</div> <div style="float:left;width:40%;margin-left:2%;">中间栏内容</div> <div style="float:right;width:30%;">右栏内容</div> </div> ### 回答2: 可以使用HTML和CSS来创建一个三栏布局,其中左右两列的宽度固定,而中间列的宽度自适应。 首先,我们需要使用HTML创建一个三列的容器,可以使用`<div>`标签来实现。代码如下: ```html <div class="container"> <div class="left-column"></div> <div class="middle-column"></div> <div class="right-column"></div> </div> ``` 接下来,我们可以使用CSS来设置样式,以实现固定宽度和自适应宽度的效果。首先,我们设置三列容器的样式,将其设置为一行布局,并使用`display: flex;`属性,使其自动伸缩。同时,设置容器的宽度为100%,以确保占据整个容器的宽度。代码如下: ```css .container { display: flex; width: 100%; } ``` 接下来,我们为左中右三列设置样式。设置左右两列的宽度为固定值,例如200像素。代码如下: ```css .left-column { width: 200px; } .right-column { width: 200px; } ``` 为了让中间列自适应宽度,我们可以使用`flex-grow`属性,设置中间列的伸缩比例为1,使其自动填充剩余的宽度。代码如下: ```css .middle-column { flex-grow: 1; } ``` 最后,为了使布局更加美观,我们可以为三列容器和内部的列添加一些样式,例如背景色和内边距。代码如下: ```css .container { background-color: #f1f1f1; padding: 10px; } .left-column, .middle-column, .right-column { background-color: #e0e0e0; padding: 10px; margin: 5px; } ``` 通过这样设置,我们就可以得到一个具有固定宽度左右列和自适应宽度中间列的三栏布局。 请注意,以上代码只是一个示例,你可以根据自己的需求进行调整和修改。 ### 回答3: 要实现一个左右宽度固定中间自适应的三栏布局,可以使用HTML和CSS进行编写。 首先,在HTML中,我们可以使用```<div>```标签来创建三个元素,分别代表左栏、中栏和右栏。例如: ``` <div class="left-column">左栏内容</div> <div class="middle-column">中栏内容</div> <div class="right-column">右栏内容</div> ``` 然后,我们需要使用CSS来设置这些元素的样式。首先,设置左栏和右栏的宽度固定,可以使用```width```属性进行设置,例如: ``` .left-column { width: 200px; } .right-column { width: 200px; } ``` 接下来,设置中栏的宽度自适应,可以使用```flexbox```布局来实现。在CSS中,将父元素设置为```display: flex;```,然后将中栏设置为```flex-grow: 1;```,这样中栏的宽度将会自适应。例如: ``` body { display: flex; } .middle-column { flex-grow: 1; } ``` 最后,可以添加一些样式来美化布局,如设置背景颜色、边框样式等。 完整的HTML和CSS代码如下: ``` <!DOCTYPE html> <html> <head> <style> .left-column { width: 200px; background-color: lightgray; } .middle-column { flex-grow: 1; background-color: white; } .right-column { width: 200px; background-color: lightgray; } </style> </head> <body> <div class="left-column">左栏内容</div> <div class="middle-column">中栏内容</div> <div class="right-column">右栏内容</div> </body> </html> ``` 通过上述HTML和CSS代码,我们实现了一个左右宽度固定中间自适应的三栏布局。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值