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.

Auto padding

Featured Replies

Is it any way how to fit menu buttons automatically in div with static width ? I have two buttons and both has same padding is it any solution how to automatically adjust padding in case that third button is added ? Keep them in a middle with same padding from cell of div and each other but with ability to adjust when next button will be added . Hopefully someone will understand my language :)

Live example here: http://jsfiddle.net/WPZ2n/

  • Author

Not exactly ... let's say we have 50px width button , and 300px width of div . In case of three buttons it should be :

 

space /button1/ space /button2/ space /button3/ space

and space = 37,5px and together with buttons width it's 300px /100%/ of div width .

 

 

If there is added fourth button I want it to automatically decrease the spaces between buttons ... it'll be 25px in this case .

 

 

But when I'm thinking about it again , it's not possible by css ...

your besst option would be this

 

 

div
{
    width:450px;
    border:1px solid red;
    
}

li,ul

{
    
    display:inline;
    border:1px dotted green;
    width:auto;
    padding:5px;
 

Edited by pat24

I'm sure theres a better way had a few beers so head not functioning

 

div
{
    width:450px;
    border:1px solid red;
    overflow:hidden;
}

ul
{ width:100%; 
    list-style-type:none;
    display:table;
    margin:0;
    padding:0;
    }
li{
   padding: 0 5px; 
   border:1px dotted green;
   display: table-cell;
  width: auto;
  text-align: center;
}
  • Author

 

I'm sure theres a better way had a few beers so head not functioning

 

div
{
    width:450px;
    border:1px solid red;
    overflow:hidden;
}

ul
{ width:100%; 
    list-style-type:none;
    display:table;
    margin:0;
    padding:0;
    }
li{
   padding: 0 5px; 
   border:1px dotted green;
   display: table-cell;
  width: auto;
  text-align: center;
}

Many thanks ... that's exactly what I've been looking for , just improved width to concrette number , and working perfect ! Thanks a lot ;)

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.