Web Design Forum  
 
Go Back   Web Design Forum > Web and Graphic Design > Web Design

Reply
 
LinkBack Thread Tools Display Modes
Old 11-18-2011, 11:00 PM   #1
New Member
 
Join Date: Nov 2011
Posts: 2
Default Stop elements from moving when resizing webpage

Hey I am trying to create a basic page with currently just two images. The problem is no matter how i set the two elements whenever I resize my webpage they end up meeting each other and overlapping. All I want to do is keep them in one position no matter what resizing is done. Kinda like in every other webpage on the internet. Here is my code.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<title>Dual Shooter</title>

<style type="text/css">
body
{
margin: 25px;
}
div#container
{
margin: 25px;
width: 800px;
position:fixed;
}
div#cod
{
position:fixed;
top:16%;
left:25%;
right:37.5%;
}
div#halo
{
position:fixed;
top:16%;
right:25%;
}
</style>

</head>

<body>

<div id="container">

<div id="cod">
<a href="cod.html">
<img src="modernwarfare3.png" alt="Call Of Duty Modern Warfare 3"/>
</a>
</div>

<div id="halo">
<a href="halo4.html">
<img src="halo4.png" alt="Halo 4"/>
</a>
</div>

<div id="footer">
</div>

</div>

</body>

</html>



Thank you
Bryanp is offline   Reply With Quote


Old 11-18-2011, 11:43 PM   #2
Diamond Member
 
Phreaddee's Avatar
 
Join Date: Feb 2011
Location: Newcastle, Australia
Posts: 1,137
Default

Stop using position fixed will be a good start.
__________________
if (headhurts == "possibly") {
alert ("keep going!");
}
else if (headhurts == "yes") {
alert ("go to sleep");
}
else if (headhurts == "damn !@#$ mofo scripts...") {
alert ("give up and have a beer!");
}
else {
alert ("watch TV");
}
Phreaddee is offline   Reply With Quote
Old 11-19-2011, 12:43 AM   #3
Diamond Member
 
Phreaddee's Avatar
 
Join Date: Feb 2011
Location: Newcastle, Australia
Posts: 1,137
Default

see position fixed fixes to the viewport and takes it out of the document flow, much like absolute, and as such, using % means that it is positioned 16%top and 25%left/right of the browser window, of course as your browser window gets smaller they will overlap, and your "wrapper" is essentially redundant.
place them within the wrapper using margins, so for instance (and of course you will need to modify to suit)
HTML Code:
<div id="wrapper">
<div id="section1"></div>
<div id="section2"></div>
</div>
Code:
#wrapper {
width:800px;
margin:0 auto;
overflow:hidden;
}

#section1 {
float:left;
width:350px;
margin:25px;
}

#section2 {
float:left;
width:350px;
margin:25px;
}
will give you 2 divs equally positioned within the wrapper, which will also be centered within the browser.

its really that simple.
__________________
if (headhurts == "possibly") {
alert ("keep going!");
}
else if (headhurts == "yes") {
alert ("go to sleep");
}
else if (headhurts == "damn !@#$ mofo scripts...") {
alert ("give up and have a beer!");
}
else {
alert ("watch TV");
}
Phreaddee is offline   Reply With Quote
Old 11-19-2011, 08:34 PM   #4
New Member
 
Join Date: Nov 2011
Posts: 2
Default

Thanks, that makes a lot more sense. I know it may seem like something so simple to both of you but I just started making webpages so I'm trying to get the basics down. And even after reading over tutorials some things don't make sense
Bryanp is offline   Reply With Quote
Old 11-22-2011, 06:59 PM   #5
Super Moderator
 
Join Date: Oct 2008
Location: Arizona, USA
Posts: 1,053
Default

@Bryanp, please search for answers to these questions prior to starting a new thread. Your problem has been solved a few times this last month in similar threads.

Glad to hear Phraeddee help you out
__________________
John Darling
Graphic / Web Designer
SmarterTools Inc.
(877) 357-6278
www.smartertools.com
PixelPusher is offline   Reply With Quote


Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:50 AM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.