I have the following html and css. But what I can't figure out is how to have the tabs div at the right of the main div. So that they stick out the right like bookmarks.
.main {
-moz-border-radius:10px;
height: 75%;
width: 60%;
position: absolute;
top: 15%;
left: 20%;
right: auto;
}
.tabs {
width: 50px;
height: 1.3em;
position: absolute;
float: right;
}
#tab { margin: 10px 10px 10px 0px;}
And the html:
<div class="main">
<div id="content">
Some main content
</div>
</div>
<div class="tabs">
<div class="tabs" id="tab1">
<a href="#" alt="Home">
Home
</a>
</div>
<div class="tabs" id="tab2">
<a href="#" alt="About">
About
</a>
</div>
</div>
With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this. With that, add height:100px and set margin.
If position: absolute; or position: fixed; - the right property sets the right edge of an element to a unit to the right of the right edge of its nearest positioned ancestor. If position: relative; - the right property sets the right edge of an element to a unit to the left/right of its normal position.
The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.
There are two general approaches to putting blocks left to right:
(1) would be:
div.main, div.tabs { display: inline; }
(2) would be:
div.main, div.tabs { float: left; }
If you do (2) put the divs in a container and add:
div.container { overflow: hidden; }
Each method has particular merits. Most notably inline
elements can't have margin
attributes applied to them. This is just one of the several constraints on inline vs block layout in HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With