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.

Positioning elements in a page

Featured Replies

Hello,

I want to create a layout like this:

post-38016-0-25726200-1336157947_thumb.jpg

 

But for some reasons the div tags does not go where i want to go.

Can you have a look at the attached index file and let me know what am i missing.

 

Note: I only worked on header part.

 

Thanks,

layout.html

#header {
 position: relative;
}
#div2, #div4 {
 position: absolute;
 top: 150px;
}
#div4 {
 top: 100px;
 right: 0;
}

 

Should move those divs where you want 'em.

 

Goodluck,

~evu.

  • Author

#header {
 position: relative;
}
#div2, #div4 {
 position: absolute;
 top: 150px;
}
#div4 {
 top: 100px;
 right: 0;
}

 

Should move those divs where you want 'em.

 

Goodluck,

~evu.

Thanks for your help.

I made a layout and I'm happy with that but the only thing that I still couldn't do is the DIV5 which isn't in the middle of the page. Do you have any solution for that?

Also can you have a look at other parts and see check if they are set correctly and won't make any problem in the future?

 

Many thanks.

layout.html

Usually, to center a div, you set a width and apply "margin: 0 auto;" to it. But you've used absolute positioning so auto wont work.

 

This'll do it though.

#div5 {
   position: absolute;
   bottom: 10px;
   width: 800px;
   height: 50px;
   background-color: #CCC;

   margin-left: -400px;
   left: 50%;
}

 

Goodluck,

~evu.

  • Author

Usually, to center a div, you set a width and apply "margin: 0 auto;" to it. But you've used absolute positioning so auto wont work.

 

This'll do it though.

#div5 {
   position: absolute;
   bottom: 10px;
   width: 800px;
   height: 50px;
   background-color: #CCC;

   margin-left: -400px;
   left: 50%;
}

 

Goodluck,

~evu.

Wow Thank you so much, It's fixed. I thought I'm good at css but still have problem in positioning ;). Anyway Thanks.

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.