Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8882029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:28:33+00:00 2026-06-14T20:28:33+00:00

I have a centered DIV, which is exactly (never more or less) 900px. I

  • 0

I have a centered DIV, which is exactly (never more or less) 900px. I want it to always be centered and have the two filler divs to fill up the rest of the page on each side…

giving the content under (using z-index) a highlighted type effect…(that’s the use of the filler divs…to show there is other content on each side of "SPOTLIGHT" content, but it’s not under the "SPOTLIGHT".

THIS CODE BELOW DOESN’T WORK…BUT IT GIVES YOU A FEELING OF WHAT I’M ATTEMPTING TO DO

CSS:

/* DIV I WANT TO BE CENTERED, SURROUNDED BY 50% OPACITY DIVS FILLING REST OF PAGE */
.shadercentered {
width:950px;
margin-left:auto;
margin-right:auto;
position:relative;
background-color:green;
height:73px;
float:left;
top:-28px
}

/* DIVS THAT FILL THE REST OF THE PAGE ON EACH SIDE OF 900px CENTERED DIV */
.shaderblindsleft {
background-color:black;
opacity:0.5;
width:fill;;
height:73px;
float:left;
position:relative;
top:-28px;
}
.shaderblindsright {
background-color:black;
opacity:0.5;
width:fill;;
height:73px;
float:right;
position:relative;
top:-44px;
}

HTML:

<div class="shaderdiv">
    <div class="shaderblindsleft">&nbsp;</div>
    <div class="shadercenter">&nbsp;</div>
    <div class="shaderblindsleft">&nbsp;</div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:28:34+00:00Added an answer on June 14, 2026 at 8:28 pm

    You get it with controlling what happens in shaderdiv with getting its children out of the flow, with position absolute.

    You put shadercenter in the middle with hooking it at left: 50%, then offseting it to the left with a negative margin-left of half its size.

    For the surrounding, you use the capabilities of constraints to define the width. For the left one, you hook it to left:0 (because it’s the left one), and then you define its right side to be where shadercenter is hooked… so it would be right: 50%. Then, you add a margin-right of half the size of shadercenter so it will be constrainted to be smaller. Use the same technic “reversed” for the right one

    <div class="shaderdiv">
        <div class="shaderblinds left">&nbsp;</div>
        <div class="shadercenter">&nbsp;</div>
        <div class="shaderblinds right">&nbsp;</div>
    </div>​
    
    .shaderdiv
    {
      position: relative;
      width: 90%;
      height: 73px;
      border: 1px solid yellow; /* debug stuff */
      box-sizing: border-box; /* debug stuff */
    }
    
    .shaderdiv > div { opacity:0.5 }
    
    .shadercenter
    {
      position: absolute;
      left: 50%;
      margin-left: -125px; /* minus half size of width */
      width:250px; /* fixed width */
      height:100%;
      background:green;
    }
    
    .shaderblinds
    {
      position: absolute;
      height: 100%;
    }
    
    .left
    {
      left: 0;
      right:50%;
      margin-right: 125px; /* half size of width */
      background:red;
    }
    
    .right
    {
      right: 0;
      left: 50%;
      margin-left: 125px; /* half size of width */
      background:blue;   
    }​
    

    Example here : http://jsfiddle.net/5kDjw/2/

    You can play with the size of shaderdiv to see that it’s fully liquid, shadercenter is always fixed width, always centered, with no overlapping

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a container div which has text within it that I want centered.
I have a title (h1) which is centered on the page. I want to
So, i have a div which i want to take up the entire width
I have a CSS two column layout which is fixed and centered. On pages
I have a div which is position:fixed so that it it always in the
i have an logo which i want centered in the header of my jq-mobile
My goal is to have several images displayed horizontally centered within a div which
I have a div general which is centered on the page. Inside I have
I want a horizontally centered floating div, i.e. one that always is on top
I have a centered div and 4 other divs - one on each side

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.