Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Position: relative to all elements?

Featured Replies

Hey guys, new to this forum and new to web designing but i'm learning through various tutorials online. All is going fairly well but I'd appreciate it if I could get few opinions of people on the positioning of elements.

I'm currently using position:relative (see excerpt below) as opposed to position:absolute or fixed/inherit .

Are there any disadvantages to this as the webpage layout does resemble the photoshop design?

 

Any info would be much appreciated.

 

******CODE********

 

#slogan {

position: relative;

top: 20px;

left: 5px;

}

 

#content {

position: relative;

top: 4px;

width: 825px; height: 680px; padding: 16px 16px 60px 16px; overflow: hidden;

color: #FFF;

background: url(images/content-bg.png);

border-radius: 3px;

-moz-border-radius: 3px;

-webkit-border-radius: 3px;

}

 

#content #slogan {

position: relative;

top: -20px;

}

 

#content #banner {

position: relative;

top: 4px;

left: 4px;

}

 

#content #information {

font-size: 14px;

text-align: justify;

width: 810px;

position:relative;

top: 30px;

left: 4px;

}

 

#content #information h2.header {

position:relative;

top:10px;

}

 

*****END CODE*********

First, use the code tags ( [ code ] [/ code ]) it makes your code allot simpler to read.

 

In my opinion, you should not be using position in this mannor, you are going to have so many issues between browsers and if the site breaks then it really breaks.

 

You should be using CSS floats to position your standard structure and then use position if/when needed for breaking box models, placing items ontop of one and another etc.

 

Here is a good reference: http://css.maxdesign.com.au/floatutorial/

  • Author

First, use the code tags ( [ code ] [/ code ]) it makes your code allot simpler to read.

 

In my opinion, you should not be using position in this mannor, you are going to have so many issues between browsers and if the site breaks then it really breaks.

 

You should be using CSS floats to position your standard structure and then use position if/when needed for breaking box models, placing items ontop of one and another etc.

 

Here is a good reference: http://css.maxdesign.com.au/floatutorial/

 

 

Thanks for replying, yeah I tried to use float to shift an object to the left/right but usually have to resort to using position as the float does not seem to have any effect.

 

But thanks for the reference.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.