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 7982795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:46:41+00:00 2026-06-04T10:46:41+00:00

I’m writing a page that looks code wise like <div class=green> <span class=orange>s1</span> <span

  • 0

I’m writing a page that looks code wise like

<div class="green">  
  <span class="orange">s1</span>
  <span class="orange">s2</span>
</div>

but that should be formated via CSS like:
Layout explanation

  • The surrounding black frame shows the full page in the browser. (Think of <body></body>)
  • The red frame is a fixed width and fixed hight basically empty space that should be added by the CSS .green:before (I’m using it’s ability to format it’s borders for a visual effect)
  • The green frame shows the real content that should be as wide as necessary to contain both <span> in one line
  • The blue frame should be created by the CSS .green:after, has a fixed height and should take up all the space till the right border of the page – i.e. it must have a variable width.

Required browsers are the modern ones (Firefox, Chrome, Safari, Opera) in recent versions. No need to take care of IE. Mobile browsers would be great, though.

How can I achieve that? (All my attempts failed sooner or later…)

A jsFiddle with this example code is at http://jsfiddle.net/X2MDG/

  • 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-04T10:46:43+00:00Added an answer on June 4, 2026 at 10:46 am

    I’m afraid that there is no way to satisfy all your constraints. The main things that don’t seem to have a CSS solution are:

    • Controlling the width of just the green bit can’t be done without affecting the width of the red :before and blue :after content. As you mention in the comments to the question, using a different DOM structure is not an option.
    • The blue (:after) content should take up all space not needed by the green (main) content.
    • The fixed height of red/blue may require some clearing on the elements below the entire div.

    So, as far as I could tell, the question as you asked it doesn’t have a 100% satisfying answer. Either way, here’s the code I came up with researching this problem, perhaps it can help you or others stumbling on this question. See either this jsfiddle or the code below:

    <div id="page">
        <div class="green">
            <span>Orange 1.</span>
            <span>Orange 2. Which can be really wide.</span>
        </div>
        <p style="clear: both;">Black is the page. Clearing is
                needed because the red and blue boxes are not in the 
                flow but do have quite some height.</p>
    </div>
    

    CSS:

    div#page { 
        border: 2px solid black;
        width: 80%;
        padding: 2px;
    }
    
    div.green:before {
        content: 'red / before';
        border: 2px solid red;
        float: left;
        display: inline-block;
        width: 140px;
        height: 200px;
    }
    
    div.green {
        border: 2px solid green;
    }
    
    div.green:after {
        content: 'blue / after';
        border: 2px solid blue;
        display: inline-block;
        float: right;
        height: 60px;
    }
    
    div.green span {
        border: 2px solid orange;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

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.