• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

css

H ii have a problem i make a div with property
width:50%
float:left;

so it make 2 box in the screen and take 50%

The problem is when i try to make padding-left:20px; in the boxes it increase size of the total div and it make it more then 50% so it go to the second line. How i can limit so it subtract from 50% - 20px left and save size of box perfect 50%.
0
umaxim
Asked:
umaxim
  • 2
1 Solution
 
Gurvinder Pal SinghCommented:
Precisely the reason why it is not always a good idea to give width/height/left/top in percentages.

However, if you want to give in percentage, then also give padding in percentage

width:45%
float:left;
padding-left:5%;
0
 
umaximAuthor Commented:
is not way to make it as specific box or something so it will not allow to change width
0
 
Gurvinder Pal SinghCommented:
But if you add 20px to 100%, then it will be overflow only.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now