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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:31:26+00:00 2026-05-30T21:31:26+00:00

i have following block of the code on my page <div style=width:100%; >//div0 <div

  • 0

i have following block of the code on my page

<div style="width:100%; ">//div0
<div style="width:50%; background:#f1f1f1; border:4px solid #fff; ">//div1
Image1
</div>
<div style="width:50%; background:#f1f1f1; border:4px solid #fff; ">//div2
Image 2
</div>
</div>

what i want is, these two div should combine to make a larger div. as their width is divided to 50% each, they should be positioned LEFT AND RIGHT TO EACH OTHER, but in reality, the div2 is positioned BELOW the div1

can somebody explain me what should i do? and what is the problem with my simple code?

  • 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-30T21:31:27+00:00Added an answer on May 30, 2026 at 9:31 pm

    This is a very basic css issue. What you should look into is the float property in CSS. Without floating, all elements on the page will be positioned one after another.

    <div style="width:50%; background:#f1f1f1; border:4px solid #fff; float: left;">//div1
    Image1
    </div>
    <div style="width:50%; background:#f1f1f1; border:4px solid #fff; float: right;">//div2
    Image 2
    </div>
    

    That should achieve what you want.

    EDIT: actually the above wouldn’t work either. Because you have a border. Think about is this way. Your page has 100% width. If your page is 1000px wide. Your divs will each take up 50% or 500px of the screen estate. Your border will take up 4 x 2 = 8px or 0.8% of the page. In total you’ll add up to 101.6% of the page. Which will force the divs to load one after another.

    To actually witness the effect of floating left and right, remove the border or reduce the width:

    <div style="width:45%; background:#f1f1f1; border:4px solid #fff; float: left;">//div1
    Image1
    </div>
    <div style="width:45%; background:#f1f1f1; border:4px solid #fff; float: right;">//div2
    Image 2
    </div>
    
    <div style="width:50%; background:#f1f1f1; float: left;">//div1
    Image1
    </div>
    <div style="width:50%; background:#f1f1f1; float: right;">//div2
    Image 2
    </div>
    

    Also note that your depending on your page width, your percentage will have different effects. The 45% and 4px border isn’t going to play along nicely all the time. If you want full screen perfectly positioned left and right box, it’s better to do it without the border and do additional styling inside each div.

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

Sidebar

Related Questions

I have the following code (on a xhtml page) <div style=background-color:#006400;> <div id=div1 style=display:inline-block;
I have the following code on my page: <p align=justify style=font-size:10pt;display:block;height:200px;vertical-align:middle;> Content </p> I
I have the following block of code that works just fine: <%@page import="java.util.*" %>
I have following HTML code: <div id=wrapper> <div class=page id=first> Test<br/> Test<br/> Test<br/> Test<br/>
Please help. I have page login/auth.gsp with the following code inside the body <div
I have the following code (available for a test run here ): <div style=margin:10px>
I have following Code Block Which I tried to optimize in the Optimized section
i have the following block of code: $(#contact_container form, #contact_details form).live( submit, function(event) {
Hi I have following code block public class Driver { static String x =
I have the following block of code which works fine; var boughtItemsToday = (from

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.