Ways to arrange two divs side by side and ensure that the content remains within the respective divs

Although I have searched for a similar solution, I haven't found an exact scenario that matches my current issue. Here is the problem: I have a div on the right (with a fixed width), and the entire left side is occupied by another div. While I can position both divs correctly, the contents of the second one are displaying below the first div. Despite trying various configurations, I have not had any success in resolving this issue. It may seem like a trivial question, but I would greatly appreciate any assistance you can offer.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">    
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>      
</head>

<body>

<div>   
    <div style="display: inline-block; width:100%; display: inline-block;"> 
        <div id="sidemenu" style="background-color: #004E87; position: fixed; width: 100px; height: 100%; float:left; display: inline-block;">
        </div>
        <div id="leftside" style="width: 100%; float:right; background-color: yellow; display: inline-block;">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        </div>
    </div>
</div>

<script type="text/javascript"> 

</script>

</body>
</html>

Updated with flex!

My current issue is achieving full screen height. Any suggestions?

<div class="flex-container" style="display: flex; width: 100%; background-color: green; align-items: stretch;">
    <div class="flex-item" style="background-color: yellow; width: 100px; height: 100%;">1</div>
    <div class="flex-item" style="background-color: red; width: 100px;">2</div>
</div>

I am grateful for any support you can provide.

Answer №1

<!DOCTYPE html>
<html lang="en>"
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">    
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-g0yqWIoXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous></script>
</head>

<body>
<div class="container-fluid">   
    <div class="row">
        <div class="col-2" style="background-color: #004E87;height:100vh">      
        </div>
        <div class="col" >
          <div class="row" style="background-color: yellow">
            <div class = "col">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
            <div>
          <div>
        </div>
        </div>
        </div>
   
</div>

<script type="text/javascript"> 

</script>

</body>
</html>

Please check if this solution suits your needs. By utilizing bootstrap, you can split a row into two columns with sizes 2 and 10 respectively to achieve the desired outcome. Feel free to reach out if you require any further assistance. Thank you :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

problem with nivo slider causing content to overflow

My webpage is using nivoslider to display images. However, I am facing an issue where the images are overflowing one by one until the page fully loads. I have tried setting the overflow:hidden property in the CSS but it doesn't seem to correct the pro ...

Steps for accessing the `<img>` tag within an `<a>` tag to focus on the `<img>` element in Internet Explorer

How can I target the img tag inside an href tag to set focus on the <img> element? For example: <a href="#"><img class="img1" src="abc.png"/></a> The CSS selector a .img1:focus {} does not seem to work. I am unable to access the ...

Prevent tooltips from displaying outside of an HTML table by using the overflow hidden property for horizontal scrolling

TL;DR: Struggling to position and display tooltips in a table due to the constraints of overflow: hidden. An example has been created to demonstrate the issue with tooltips not displaying correctly within a table. The problem arises because the table nece ...

Reveal/Conceal footer upon vertical scrolling

I am attempting to achieve the following goals: Display the div element when the scrolling position is greater than 20 Apply a fadeOut effect after a certain delay Prevent the fadeOut effect when hovering over the sticky footer This is my implementation ...

Position the table cells at the corner so they align on the same row as a table row, even if the cells are from a different table with

I am working with two tables, each containing two columns – meaning there are two td elements for every tr. If the last tr of the first table has only one td element, it will result in a blank space at the end. This issue can be resolved by using colspan ...

Strategies for identifying specific children in my particular situation

Here's a snippet of my code: <ul id='nav'> <li><h1 id='unique' class='title'>Topic</h1></li> <li><h1 class='toptitle'>Department</h1></ ...

The issue of app.css and app.js resources not loading in Laravel 8 with nginx, resulting in a 404 not found error, needs to be

Although this question may appear to be a duplicate, I assure you it is different. I have thoroughly searched through Stack Overflow, Laracast, Reddit, and GitHub for a solution. My setup includes a Laravel application on an Ubuntu VM with Nginx. The pro ...

Footer mysteriously appears on top of the container

Trying my hand at practicing HTML by creating a small webpage, but struggling with why the Footer is aligning itself under the Header instead of the container I set up. It seems like a small detail that I might have missed, but I've hit a wall and ca ...

loop not functioning properly with file type input

Having trouble uploading an image and copying it into a folder named images within a loop. Can you assist with solving this issue? Here's my code: $sql="SELECT * FROM product"; $q=$conn->query($sql); while($r=$q->fetch(PDO::FETCH_ASSOC)) { $cod ...

Can CSS be used for creating unique color combinations?

I am facing a challenge where I have two div elements with different transparent, colored backgrounds that overlap each other. My goal is to find a way to customize the color in the area where these elements overlap. For instance, if I blend red and blue ...

Rotating Social Media Symbols - bootstrap 4

I am looking to incorporate a Social Button Footer similar to the one in this CodePen example: (https://codepen.io/vpdemo/pen/WbMNJv). However, my buttons are not appearing as circles. How can I rectify this? a, a:hover { text-decoration: none; } .soc ...

Customize CSS to target the first and last elements in a row using flexbox styling

I am facing a challenge in selecting the last element of the first row and the first element of the last row within a flex container. The setup involves a flex-wrap: wrap; for my flex container where all elements have flex: auto; with different sizes. Thi ...

What is the process for implementing custom CSS styles in Cognos?

I've been working on creating Cognos reports and I'm looking to change the overall design of some specific ones (prompt pages and report pages). Is there a way for me to use different custom CSS files for each individual report? If that's ...

Seeking a light-weight, text-rich editor specifically designed for use on our enterprise website. This editor should be even lighter than TinyMCE

I am in search of a lightweight text editor for an enterprise website, lighter than tinymce with basic buttons for the comment form. It is imperative that the editor also functions properly in IE6. So far, I have tried cleditor 15KB, but it has an issue in ...

Images displayed using jQuery do not fade into view

I have a collection of JSON image URLs that I am using to populate a div with a variety of images. Initially, the images are set at opacity 0 and should gradually fade in through a for loop. Here is the jQuery code snippet: $.ajax('http://example.co ...

Fluid container and confined container

Can someone explain the guidelines for when to use container versus container fluid in web development? What are some best practices and common pitfalls to avoid when using these two options? I would appreciate a clear explanation of the differences betwe ...

Troubles arise when attempting to load the imported Segoe UI semilight font in CSS

Segoe UI semlight is a font created specifically for Windows 7 that I adore. In fact, I am currently developing a web application and decided to use this font in it. However, I encountered an issue when trying to make the font compatible with other opera ...

Including a pointer image in an image map

Here is a CSS image map setup that I've been using: HTML: <div style="display:block; width:791px; height:1022px; background:url(images/image.jpg); position:relative; margin:2px auto 2px auto;"> <div><a class="imagemaplink" style="left: ...

Assistance with w3 Validation for Blogger Template

Can anyone help me with fixing code errors in my custom blogger template? I downloaded it from another blog site, and while the front end looks good, I am facing a lot of issues with W3 validation due to errors in the HTML code. Here is the link to my site ...

The CSS code does not seem to be applied when using HTTP, however, it

After hosting my website, I noticed an issue with my CSS stylesheets. When I access my site using www.example.com, everything displays correctly. However, if I use the address http://example.com, only the HTML body shows up without any CSS styling. Can a ...