• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • 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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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