如何根据需要更改div长度? [英] How to I make div length changes as needed?
问题描述
我想根据搜索结果使用循环制作一个长度可变的div,但看起来css看不到php循环,因为div的长度仍未改变,这是php代码
I want to make a div with a length changable according to search results using a loop, but it looks like the css can't see the php loop because the length of the div still unchanged, this is the php code
<html>
<head>
<link rel="stylesheet" type="text/css" href="Styles\style.css"/>
<title>iFound</title>
</head>
<body dir="rtl">
<div id="MainDiv">
<div id="Headin"></div>
<div id="Nav"></div>
<?php
for($i=0;$i<9;$i++)
{
echo "<div class=\"divs\"><div class=\"indivs\"></div><div class=\"intxtdivs\"></div></div>";
}
?>
<div id="footer"></div>
</div>
</body>
</html>
CSS代码
CSS code
body{
padding:0;
margin: 0;
background-color: #3778a1;
}
#MainDiv{
background-color: white;
margin-left: auto;margin-right: auto;margin-top: 5px;
width: 1000px;
min-height: 500px;
}
#headin{
top: 0;
width: 100%;
height: 100px;
border-bottom: 1px solid black;
}
#nav{
width: 100%;
height: 49px;
border-bottom: 1px solid black;
}
.divs{
width: 298px;
height: 298px;
border: 1px solid black;
margin-right: 26px;margin-top: 50px;
float: right;
}
.indivs{
width: 290px;
height: 220px;
margin-left: auto;
margin-right: auto;
margin-top: 6px;
margin-bottom: 6px;
background-color: yellow;
}
.intxtdivs{
width: 290px;
height: 60px;
margin-left: auto;margin-right: auto;
position: relative;bottom: 0;
background-color: aqua;
}
#footer{
bottom: 0;
width: 100%;
height: 50px;
background-color: black;
}
https://s14.postimg.org/vrktds0xt/111.jpg [ ^ ]
我该怎么办?
我的尝试:
我试着设置auto和100%的长度,但它没用!
https://s14.postimg.org/vrktds0xt/111.jpg[^]
what should i do?
What I have tried:
I tried to set the length auto and 100% but it is useless!
推荐答案
i = 0;
i< 9;
i ++)
{
echo < div class = \divs \\ \\>< div class = \indivs \>< / div>< div class = \intxtdivs \>< / div>< / div>跨度>;
}
?>
< div id = 页脚 > < / div >
< / div >
< / body >
< / html >
i++) { echo "<div class=\"divs\"><div class=\"indivs\"></div><div class=\"intxtdivs\"></div></div>"; } ?> <div id="footer"></div> </div> </body> </html>
CSS代码
CSS code
body{
padding:0;
margin: 0;
background-color: #3778a1;
}
#MainDiv{
background-color: white;
margin-left: auto;margin-right: auto;margin-top: 5px;
width: 1000px;
min-height: 500px;
}
#headin{
top: 0;
width: 100%;
height: 100px;
border-bottom: 1px solid black;
}
#nav{
width: 100%;
height: 49px;
border-bottom: 1px solid black;
}
.divs{
width: 298px;
height: 298px;
border: 1px solid black;
margin-right: 26px;margin-top: 50px;
float: right;
}
.indivs{
width: 290px;
height: 220px;
margin-left: auto;
margin-right: auto;
margin-top: 6px;
margin-bottom: 6px;
background-color: yellow;
}
.intxtdivs{
width: 290px;
height: 60px;
margin-left: auto;margin-right: auto;
position: relative;bottom: 0;
background-color: aqua;
}
#footer{
bottom: 0;
width: 100%;
height: 50px;
background-color: black;
}
https://s14.postimg.org/vrktds0xt/111.jpg [ ^ ]
我该怎么办?
我的尝试:
我试着设置auto和100%的长度,但它没用!
https://s14.postimg.org/vrktds0xt/111.jpg[^]
what should i do?
What I have tried:
I tried to set the length auto and 100% but it is useless!
这篇关于如何根据需要更改div长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!