Solved

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

Posted on 2007-11-28
7
1,842 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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 18

Expert Comment

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

Author Comment

by:detox1978
Comment Utility
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
Comment Utility
You just need to set the margin-right and margin-left to 50px.  Then you div will be 100% - 100px
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

by:R7AF
Comment Utility
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 200 total points
Comment Utility
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 50 total points
Comment Utility
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
Comment Utility
thanks.  i nested a span inside.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now