I have one Parent div开发者_StackOverflow社区. Top of the Parent div contains two child divs. How can i give third child div below the first child div
<div class=parent1>
<div class=child1>some text</div> /*this is in top left of the parent div */
<div class=child2>some text</div> /*this is in top right of the parent div */
<div class=child3>some text</div> /*how can i write css for this div come as left bottom*/
Using the css float will work if you are willing to assign a fixed width to your div's.
<style>
div.parent1 {
width: 800px;
}
.child1 {
float: left;
width: 400px;
}
.child2 {
float: right
width: 400px;
}
.child3-container {
clear:both;
text-align: right;
}
</style>
<div class=parent1>
<div class=child1>some text</div>
<div class=child2>some text</div>
<div class='child3-container' >
<div class=child3>some text</div>
</div>
</div>
You can put jQuery to use to do the job easily. Use the eq() selector of jquery to get you the desired div:
$('div#parent div:eq(1)'); // gets second div inside a div with id parent
How can i give third child div below the first child div
If I get you, you want to add another div after the first child div, you can again use eq and after selector for that:
$('div#parent div:eq(0)').after('<div>Some Content</div>');
Update:
Here is the demo I created for that
The idea is that parent div should be positioned relative and child divs absolute and then using top, left, width and height properties.
加载中,请稍侯......
精彩评论