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

  • Home
  • SEARCH
  • 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 7617047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:02:51+00:00 2026-05-31T03:02:51+00:00

How do I make a block-level element, such as a div stretch to the

  • 0

How do I make a block-level element, such as a div stretch to the available width?

I know that this may seem like a question with an obvious answer, but it is a tad bit more complicated that it seems, have a look at this Fiddle:

http://jsfiddle.net/spryno724/pZKgv/

The CSS sets a left and right margin for the containing div to 20% on each side. Setting the width property causes it to stretch 100% of the original available space, causing it to spill off the side of the screen when the 20% margins are added to each side.

How can this be fixed, such that 20% margins still exist, but the div stretches to fill the remaining space in between?

  • 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-05-31T03:02:52+00:00Added an answer on May 31, 2026 at 3:02 am

    This is what you had:

    .error {
      border: 1px solid black;
      display: inline-block;
      margin-left: 20%;
      margin-right: 20%;
      position: fixed;
      top: 0;
      width: 100%;
    }​
    

    Try this one:

    .error {
      border: 1px solid black;
      margin-left: 20%;
      margin-right: 20%;
      top: 0;
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got stuck while trying to make an element in website behave like this: <div
In C# you can make a block inside of a method that is not
I have often wrapped block level elements with <a> tags in order to make
I know that this has been asked a million times before, but nothing that
I am trying to make a table-like calendar page, using fixed width and height
I want my language to have two features that make Python such a nicely
I need to make tabs like this which is having horizontal scroll and I'm
How to make a block of memory allocated by malloc() or new: immediately swapped
I want to make two block stand side by side. In Opera, Chrome and
Apple says about the UITableView -beginUpdates -endUpdates block: If you do not make the

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.