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.

Need some help with left and right css format

Featured Replies

Hi, need some help with aligning div left and another div right on the same level.

 

Everything looks ok on my laptop but when I view it on a 22” screen there’s a big cap between the two div’s

 

Code below

 

left {

position: absolute;

top: 153px;

left: 95px;

width: 300px;

height:58px;

/*background-color: #E8EAEB;*/

 

}

.right {

 

position: absolute;

top: 170px;

right: 995px;

width: 30px;

height: 48px;

background-color: #888;

 

}

A blind guess.

 

left {
    Float:left; 
   Margin-top: 153px;   
   Margin-left: 95px;   
   width: 300px;  
    height:58px;  
  /*background-color: #E8EAEB;*/  }

.right {    
Float:right;  
  Margin-top: 170px;    
  width: 30px;   
  height: 48px;   
  background-color: #;

Best thing to do when you have a coding issue like this is to fire up jsFiddle and put it in there, then we can see a live version.

With just looking at your code though, the use of all those 'magic numbers' is a bit alarming, but it's hard to reason because we cannot see a live version.

 

Going with floats like Fuzzy posted sounds about right, but again, hard to tell with no live version. One thing to note is that if you are floating things like this you will need to add in a clearfix to the floated elements container to prevent it from collapsing.

Best thing to do when you have a coding issue like this is to fire up jsFiddle and put it in there, then we can see a live version.

With just looking at your code though, the use of all those 'magic numbers' is a bit alarming, but it's hard to reason because we cannot see a live version.

 

Going with floats like Fuzzy posted sounds about right, but again, hard to tell with no live version. One thing to note is that if you are floating things like this you will need to add in a clearfix to the floated elements container to prevent it from collapsing.

 

Yeah those magic numbers are a touch confusing, they don't add up. I can see the first problem with the OP code is absolute positioning without a relative wrapper of some sort, that's where I guess the spacing is coming from but those numbers (top and height) don't add up to the same total height, very confusing.

 

Here's a jsfiddle at what i'm guessing the op was trying to do?

Edited by BrowserBugs

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.