cjy8s@yahoo.com Posted February 13, 2012 Share Posted February 13, 2012 Hey! So I have an intersting situation:I am trying to make a div stop moving left past a certain point when the browser is resized. But in the method I am using, I can no longer position the Div to sit exactly where I want! I want it to float: left at 50%, and be offset left by about ~150px. My code looks like this: div.main_content {padding: 0 195px;margin: 0 auto;}div.inner_content {position: relative;float: left;top: 150px;left: 50%;margin: 0 auto;min-width: 400px;border: 1px solid #000000;background-color: #A0CFEC;text-align: justify;overflow: hidden;}<div class="main_content"><div class="inner_content"><p>veruib eribwe vbeuvip eurbvpe bvp2398bp2 3ivb wep rbpwbc ;fcwpvf vpw78 b2 wevbc73h fpf8 g fwgfb o47 gwi bo87e</p><p>veruib eribwe vbeuvip eurbvpe bvp2398bp2 3ivb wep rbpwbc ;fcwpvf vpw78 b2 wevbc73h fpf8 g fwgfb o47 gwi bo87e</p><p>veruib eribwe vbeuvip eurbvpe bvp2398bp2 3ivb wep rbpwbc ;fcwpvf vpw78 b2 wevbc73h fpf8 g fwgfb o47 gwi bo87e</p><p>veruib eribwe vbeuvip eurbvpe bvp2398bp2 3ivb wep rbpwbc ;fcwpvf vpw78 b2 wevbc73h fpf8 g fwgfb o47 gwi bo87e</p><p>veruib eribwe vbeuvip eurbvpe bvp2398bp2 3ivb wep rbpwbc ;fcwpvf vpw78 b2 wevbc73h fpf8 g fwgfb o47 gwi bo87e</p><p>veruib eribwe vbeuvip eurbvpe bvp2398bp2 3ivb wep rbpwbc ;fcwpvf vpw78 b2 wevbc73h fpf8 g fwgfb o47 gwi bo87e</p><p>veruib eribwe vbeuvip eurbvpe bvp2398bp2 3ivb wep rbpwbc ;fcwpvf vpw78 b2 wevbc73h fpf8 g fwgfb o47 gwi bo87e</p></div></div> Again, my problem is that now the div sits at exactly 50%, as expected, and overflows off the screen. What I need is a way to offest the div a little to the left, similarly to this: div.main_content {position: absolute;float: left;left: 50%;margin-left: -150px;} As far as I can tell, the div does not stop at a certain point when the browser is resized if I use this method. Any suggestions? Thank you!! Link to comment Share on other sites More sharing options...
regicidedelferoz Posted February 14, 2012 Share Posted February 14, 2012 you have to put the exact width of the div then add this code margin-left:auto;margin-right:auto; Link to comment Share on other sites More sharing options...
cjy8s@yahoo.com Posted February 14, 2012 Author Share Posted February 14, 2012 Thats the thing though, this is to uploaded to Wordpress, so the width of the div could be changed by the owner at any point. depending on their content. Thank you, any other suggestions? Link to comment Share on other sites More sharing options...
regicidedelferoz Posted February 14, 2012 Share Posted February 14, 2012 sorry but i had also search for it but the internet people says you have to set the specific width of your div,.. Link to comment Share on other sites More sharing options...
dsonesuk Posted February 14, 2012 Share Posted February 14, 2012 I still can't gather what you are trying to achieve? wouldn't the amount of overflow off the screen as you put it, depend on screen width, and resolution, and by using position: absolute; that element is taken out of the flow of the document, so knowing where this element area finishes or starts is not distinguishable from any element or browser screen edges, so it will just overlap without any scroll bars appearing when it does so. Link to comment Share on other sites More sharing options...
cjy8s@yahoo.com Posted February 15, 2012 Author Share Posted February 15, 2012 Yah!! i got it Thank you, Regicide Del Feroz, you were right, I just set a Left: value and adjusted the padding and it worked out exactly how I wanted. And thank you, dsonesuk, for the affectionate "B**** Please!". Haha It slapped me in just the right way. I forgot I had switched to the relative position since. Anyway, Thank you guys again! Always well appreciated! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.