2 <div> s in <div>
4 answers
How about this? The only fixed thing you need to set is the margins of the inner div, but that shouldn't hurt since you didn't talk about any marginal restrictions in the comments on this topic. As for styles, only borders are purely presentation, the rest are the minimum required styles.
<!doctype html>
<html lang="en">
<head>
<title>SO question 1892901</title>
<style>
#main {
position: relative;
width: 500px;
height: 300px;
border: 1px solid black;
}
.inner {
position: absolute;
top: 0;
bottom: 0;
margin: 20px;
border: 1px solid black;
}
.inner.left {
left: 0;
right: 50%;
}
.inner.right {
right: 0;
left: 50%;
}
</style>
</head>
<body>
<div id="main">
<div class="inner left">inner left</div>
<div class="inner right">inner right</div>
</div>
</body>
</html>
I have to add, strict doctype is very important , otherwise IE will not work due to an error .
+1
:
<table>
<tr>
<td>Div 1 content here</td><td>Div 2 content here</td>
</tr>
</table>
tds , , , .
: , , "". , . . , , css, . , div - - .
2: , :
<html>
<head>
</head>
<body>
<style>
div { width: 100px; height: 30px; border: 1px solid red; margin: 0 auto 0 auto; text- align: center; }
table { border: 1px solid blue; width: 400px; }
td { padding: 20px 0 20px; }
</style>
<table>
<tr>
<td> <div class="one">div 1</div> </td>
<td> <div class="one">div 2</div> </td>
</tr>
</table>
</body>
</html>
. divs, .
-4