The responsiveness of my flexbox containers is compromised when using flex-direction:column

I recently started learning flexbox and I'm having trouble understanding it.

My header is somewhat responsive, and when I resize my browser window, it adjusts very well. However, the container below with flex-direction: column behaves strangely (try resizing yourself), as it goes off my screen while the elements inside remain in their places. If I set it to flex-direction: row, it works just like the header.

Any suggestions on how to fix this?

Here's the link to the project: https://codesandbox.io/s/dazzling-cerf-qbbwi?file=/index.html

    <style>
    header {
        width: 100%;
        background: #669966;
        height: 81px;
        display: flex;
        justify-content: center;
        box-shadow: -2px 8px 15px 0 rgba(0, 0, 0, 0.29);
    }
    
    .container {
        width: 1400px;
        margin: 0 auto;
    }
    
    .header-wrap {
        width: 1400px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 81px;
        overflow: hidden;
        padding: 0 50px;
    }
    
    .menu {
        width: 500px;
        display: flex;
        justify-content: space-between;
    }
    
    .menu li {
        display: inline;
        font-family: Open Sans;
        font-size: 18px;
        line-height: 25px;
        color: #DFDFDF;
    }
    
    ...

            </div>
            <

Answer №1

Avoid using fixed widths in your project

.top-container1-top {
        width: 1400px;
}

Using fixed widths for different containers is causing issues in your code. Utilize Flexbox to handle spacing automatically - just familiarize yourself with basic flexbox properties.

Check out the updated CodeSandBox link for a working example: https://codesandbox.io/s/clever-cloud-ppz04?file=/index.html

You can make minor adjustments as needed. Everything should be functioning properly now.

Remember to implement media queries for smaller screens based on your requirements. :)

Answer №2

Have you considered using a percentage width instead of a fixed value? This will allow your container to be more flexible and adapt to different screen sizes.

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

Executing Javascript without invoking the default behavior

Recently, I've been delving into the world of JavaScript and experimenting with the prevent default command for ajax pagination. Here's the code I've come up with: http://jsfiddle.net/6pqfH/2/ $('.pagination').click(function(e){ ...

What is the best way to position a banner image behind the navigation bar on my website?

I'm struggling to position the banner image behind the navigation bar on my website. It keeps appearing below the navigation bar, but I want it to be positioned behind the navigation bar instead. Here is the code I'm using: * { margin: 0; ...

Converting Django variables into formatted HTML content

My Django project involves passing strings to my HTML template. def media(request, media_id): specificMedia = get_object_or_404(Stream, pk=media_id) channel = str(specificMedia.channel) urldata = "http://www.twitch.tv/widgets/live_embed_player ...

Error message: Uncaught SyntaxError: Unexpected import token encountered in (ReactJS, Babel, Webpack, NodeJS)

I've been struggling for days to get this simple Hello World app working using ReactJS and Babel. I have installed node.js and webpack, but unfortunately, I keep encountering the following error: Uncaught SyntaxError: Unexpected token import Below ...

Stylesheets may not display correctly in Firefox and IE

Just wanted to say that I recently put together this little website , but I am completely stumped on why the CSS file won't show up in Firefox or IE. I know it's a basic question, but I'm still learning all of this. Thank you so much for a ...

Why won't the jQuery function trigger when I click, but only responds when I move the cursor?

I am currently working on a website that includes a basic CSS style switcher. The function responsible for handling the theme button clicks is shown below: <script> $(function() { $(".light").click(function(){ $("link").attr("href", ...

Is it possible to create a column break within a CSS multicolumn design?

My text content sprawls over a CSS multicolumn layout with two, three, or four columns, utilizing CSS hyphenation. Sometimes, I want to terminate the text in one column early to allow the next paragraph to begin at the top of the next column. Is there a s ...

Trick for using :checked in CSS

Is it possible to change the color of a deep linking div using an input checkbox hack in the code below? <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /&g ...

The placement of an object on a webpage

Seeking the (x,y) coordinates of an element using JavaScript, utilizing the offset property from jQuery. Here is my code snippet: var offsets = $('#11a').offset(); var top = offsets.top; var left = offsets.left; console.log("Coor ...

How to design <p> elements inside a bordered container?

I am currently working on a webpage that features text enclosed in bordered boxes with styled formatting. The primary issue I am encountering is that when I try to add another paragraph within the styled <p> tag containing the border styling, the su ...

How can a User Control in ASP.NET generate a new CSS class dynamically?

Within my UserControl, there is an AJAX modal popup extender that is causing me some trouble: <ajax:ModalPopupExtender ID="MPE" runat="server" TargetControlID="btnChangePassword" PopupControlID="pnlPasswordChanging" BackgroundCssClass="modalBackgrou ...

Ways to toggle the display of a div depending on various radio button selections

Currently, I am working on a project using HTML along with Bootstrap and Jquery. My objective is to dynamically hide a div based on the selection of multiple radio buttons without requiring a submit button. The code snippet that I have provided below works ...

Using jQuery to submit a form and update values

I am currently working with a datatable that includes a detail column with an edit button. Upon clicking the edit button, I pass the ID as a parameter and fetch all the values associated with that ID to display in a form. However, when I edit the values an ...

Problem with the overflow setting of a specific div

My website is currently hosted on a test server at medexcel.comeze.com. However, I am encountering an issue where the overflow of the top div is no longer hidden when I hover over a menu button in the top bar. This results in the bottom right corner of th ...

JavaScript's click() function cannot be used on text areas

Currently, I am in the process of creating a script for automating comments. During step one, I encountered an issue where the code is expected to simulate a click on this text area within a red box, but unfortunately nothing happened. Initially, I attem ...

Is there a way to prevent my navbar from breaking buttons on mobile devices?

I am a beginner working on my practice portfolio and I have decided to make it fully responsive using flexbox as much as possible. I am following a "mobile-first" approach, so I can address any design issues for desktop later on. One problem I am facing is ...

Vanishing Submenus

I'm experiencing an issue with my navbar and its drop-down menus. When I hover over the submenu, it doesn't stay visible as expected. I've tried different approaches such as using jQuery, the + operator in CSS, and even creating a separate h ...

Guide to adding a personalized image to the header of a Shiny plot?

In the code snippet provided below, I am attempting to incorporate a custom image into the header of a plot. In my application, clicking on this image triggers a modal dialogue with further explanation. However, I am encountering difficulties in getting th ...

Tips for ensuring the pop-up submenu remains visible even when the cursor is outside the parent container and submenu during hover

Is there a way to keep the pop submenu visible even when the mouse hovers outside of its parent container or the submenu? Currently, if the mouse doesn't move straight down from the parent container (B) .account-settings-container to the top arrow of ...

Is Bootstrap revolutionizing the world of flex-box layouts?

I'm currently in the process of creating a Simon game, and everything is going smoothly until I introduce Bootstrap into the mix. Suddenly, my "Simon board" starts acting strangely. Here's the troublesome code: HTML: <div class="simon"> ...