floating div
- Started
- Last post
- 9 Responses
- Atkinson
I have <div id="main"></div>
Within that div, how do I creat a div that sticks to the top right corner? I can't get my head around it!
- jamble0
Give that div a position:relative then create your new div inside, give it position: absolute and top: 0 right: 0
Should do the trick.
- JamesBoynton0
<div id="main">
<div id="float"></div>
</div>#main {
width:whatever}#float {
float:right}
- PSYKHO0
Damn beat me to it!! :)
- JamesBoynton0
sorry, thought you wanted it done with floating... jambles way is best.
- Atkinson0
will these methods work across browsers though? I thought absolute positioning wasn't a good thing? Here's the main style
#main{
overflow: auto;
float: left;
position: absolute;
top: 0px;
right:0px;
bottom:0px;
left: 200px;
padding-left: 20px;
vertical-align: top;
z-index: 3;
text-align: left;
width: auto;
background-color:#999999;
}- IE6 throws a bit of a flid when you use fixed positioning but absolute should be alright.jamble
- JamesBoynton0
You have position:absolute and float:left on it, not sure if that works... may be wrong though, i would try and tidy that up a little, but yeah, the absolute should work cross browser, as will the float option i pointed out above.
- JamesBoynton0
Maybe upload the page so we can see what you are working on. Cheers.
- jamble0
http://welcomebrand.co.uk/gubbin… (view source)
Works in FF, IE7 and IE6. I couldn't be fucked to check it in anything else but it's a start.
