自动调整包含其他两个div的div

时间:2016-04-01 17:37:21

标签: html css



@media only screen and (min-width: 900px) {
  .map_left {
    display: inline; 
    float:left; 
    width: 100px;
    height: 100px;
    border: 3px solid green;
  }

  .map_right { 
    display: inline; 
    float:right;
    width: 100px;
    height: 100px;
    border: 3px solid blue;
  }
}




为什么第一个div(包含另外两个div)不会自行调整大小?我不想用像素设置宽度和高度,我想让它自己调整大小,是否可能?



<!DOCTYPE html>
<html>
  <head>
    <link type="text/css" rel="stylesheet" href="prova.css"/>	
    <title></title>
  </head>
  <body>
    <center><div style="border: 3px solid">
      <div class="map_left" width="90%"></div>
      <div  class="map_right" width="90%"></div>
    </div></center>
  </body>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

因为您设置了witdth="1000px",所以放置xxx%或者没有(默认为100%)

答案 1 :(得分:0)

<!DOCTYPE html>
<html>
	<head>

		<link type="text/css" rel="stylesheet" href="prova.css"/>	

		<title></title>
	</head>

	<body>
   

<center><div style="border: 3px solid;width:100%">


<div class="map_left" width="90%">

</div>

<div  class="map_right" width="90%">

</div>


</div></center>



</body>