Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

css

Posted on 2011-09-08
3
Medium Priority
?
180 Views
Last Modified: 2012-05-12
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
Comment
Question by:umaxim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 2000 total points
ID: 36503880
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
 
LVL 1

Author Comment

by:umaxim
ID: 36503916
is not way to make it as specific box or something so it will not allow to change width
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 36503976
But if you add 20px to 100%, then it will be overflow only.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question