CSS: is it possible to set a DIV width to 100% minus 100px?

Hi All,


Title say it all really.

is it possible to set a DIV width to 100% minus 100px, using CSS?


Many thanks
LVL 2
detox1978Asked:
Who is Participating?
 
rbudjConnect With a Mentor Commented:
oh, for color, make a div set to 100% , then put another div inside that div following my previous instructions.  Make the background color of the container div whatever color you want and it will show through where the right and left margins are 50px
0
 
Eternal_StudentCommented:
Is the 100px going to be used for anything?
0
 
detox1978Author Commented:
I'm creating a block of colour for decoration.  Here's what i have (the width doesn't work).


#extraDiv1 {
      position:absolute;
      top:0px;
      right:0px;
      width: 100% - 100px;
      height:100%;
      background-color:#FF9933;
      z-index:-10;
}
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
rbudjCommented:
You just need to set the margin-right and margin-left to 50px.  Then you div will be 100% - 100px
0
 
R7AFCommented:
Create another div around it and add padding to that div. It depends a little where you want to place the inner div, but this is a possibility:
div.container { padding-right: 100px; }

Open in new window

0
 
Eternal_StudentConnect With a Mentor Commented:
Yes there are numerous ways to do this.

<div style="width:100%;">
      <div style="float:right; background-color:#FF0000; width:100px;">&nbsp;</div>
</div>
0
 
detox1978Author Commented:
thanks.  i nested a span inside.
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.

All Courses

From novice to tech pro — start learning today.