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

x
?
Solved

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

Posted on 2007-11-28
7
Medium Priority
?
1,871 Views
Last Modified: 2008-02-01
Hi All,


Title say it all really.

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


Many thanks
0
Comment
Question by:detox1978
[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
  • 2
  • 2
  • +1
7 Comments
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 20365850
Is the 100px going to be used for anything?
0
 
LVL 2

Author Comment

by:detox1978
ID: 20365870
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
 
LVL 16

Expert Comment

by:rbudj
ID: 20365928
You just need to set the margin-right and margin-left to 50px.  Then you div will be 100% - 100px
0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
LVL 13

Expert Comment

by:R7AF
ID: 20365936
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
 
LVL 16

Accepted Solution

by:
rbudj earned 800 total points
ID: 20365955
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
 
LVL 18

Assisted Solution

by:Eternal_Student
Eternal_Student earned 200 total points
ID: 20365994
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
 
LVL 2

Author Comment

by:detox1978
ID: 20366017
thanks.  i nested a span inside.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
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 …
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

705 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