Tips for creating a flexbox layout that is responsive to different screen

Currently, I am using flex to ensure that the two inner div elements have the same height. However, the design is not responsive as it appears perfectly in a full-width window but gets squeezed on mobile devices.

Is there a solution to this issue?

Are there alternative methods to achieve equal heights for the two side-by-side divs without setting a fixed height property due to dynamic data?

For more details, please refer to my fiddle link: link

.image-bg-fluid-height {
  background-color: black;
  padding: 51px 0 0 0;
}

<!-- More CSS code here -->

.modal-dialog {
  display: inline-block;
  text-align: left;
  vertical-align: middle;
}

.ui-autocomplete {
  position: absolute;
  cursor: default;
  z-index: 30 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<header class="image-bg-fluid-height" style="display: flex;">
            <div class="col-md-8 gradient-background">
                <!-- HTML structure -->
                <!-- More HTML code here -->
    </header>

Please note: The top black part serves as padding for my header section.

Thank you.

Answer №1

It may not be ideal to mix CSS stylesheets with inline attributes, but by utilizing bootstrap, you can easily make your layout responsive. Simply add class="col-md-8 col-xs-12", which will use 8 out of 12 columns on medium screens and all 12 columns on smaller screens.

However, if your display: flex; property is preventing the elements from adjusting width based on bootstrap's grid system, you can use a media query like @media (min-width: 992px), which targets the default medium view in bootstrap.

@media (min-width: 992px) { .image-bg-fluid-height { display: flex; } }

<header class="image-bg-fluid-height">
    <div class="col-md-8 col-xs-12 gradient-background">...</div>
    <div class="col-md-4 col-xs-12" style="background-color: #FAFAFA;">...</div>
</header>

Check out the JSFiddle demonstration here: https://jsfiddle.net/Zay_DEV/yc92u1g2/1/

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

Tips for preventing breaks in typography

I have implemented a material ui Typography component, but it's causing a line break even though there is enough space. Here is the code snippet: <Box flexDirection="row"> <Typography> Gender: <RadioGroup row ...

Issue with Bootstrap 4 Multi Select Functionality in Modal Not Functioning

Having trouble getting a bootstrap multi-select dropdown to work inside a Bootstrap modal. When the modal opens, the following CSS is affecting the dropdown: select.bs-select-hidden, .bootstrap-select > select.bs-select-hidden, select.selectpicker { ...

What is the best method for obtaining a modified image (img) source (src) on the server side?

Having some trouble with a concept in ASP.Net that's causing me quite the headache. I am fairly new to ASP.Net and struggling with something that seems much easier in PHP. I created an img element with an empty src attribute : <img runat="server" ...

Methods to validate CSS attributes specified within a class using React testing library

I am struggling to validate the CSS properties defined within a class in CSS using the React Testing Library. Unfortunately, I am facing challenges in doing so. Here are the simplified code snippets: import React from "react"; import { render, ...

What are some ways to create a responsive Grid in React JS with the help of Bootstrap?

Utilizing bootstrap in my react js project, I am implementing css grid to showcase some cards. However, I am encountering responsiveness issues. import React from "react"; import "./Project.css"; export const Project = () => { return ( <div& ...

Modify the background color of the entire page when the main div is clicked

I am attempting to alter the background color of my entire page when the div with id main is clicked. You can view the code here: $(document).ready(function() { var color = 1; $('#main').click(function(){ if (colo ...

Which html parsing tool is capable of processing encoding?

The journey begins -- I have a file saved on my computer that is an HTML page. When I view it in a regular web browser, the correct characters are displayed regardless of the encoding used. Then comes the challenge -- my task is to load the same file, par ...

Function in head not triggering on OnMouseOver event

My goal is to have specific text display on my page when a user hovers over an image, with the text changing for each image. Below is the code snippet for the header section: <head> <title>Indian Spices Page</title> <link rel="s ...

Insert a picture within the text input field

I'm facing a specific scenario where I need to add text followed by an image, then more text followed by another image and so on. Please see the input text with values in the image below. Can someone guide me on how to accomplish this with jQuery and ...

"Explore the dropdown options on the Twitter Bootstrap menu by hovering your cursor

Is there a way to modify the code so that when hovering over a dropdown menu created with Twitter Bootstrap 3, the menu expands and users are able to click on the expanded links? The HTML code I came up with is as follows: <nav> ...

The vertical-rl writing mode fails to function properly when the website is viewed within the Facebook app

I am facing an issue with a vertical button on my website. It works fine in browsers, but when the webpage is shared on Facebook and opened within the Facebook app, the button's alignment gets distorted. How can I resolve this problem? <div class= ...

Detecting the scroll events of elements with the overflow:hidden property

Looking to synchronize scrolling between two different panels or divs? In one element, there's an overflow: auto while the other has overflow: hidden (trying to mimic a grid with frozen columns). I've managed to sync the scroll when it occurs w ...

Override current website to display the mobile version

Few limitations to consider. Dealing with Sharepoint 2013, which can cause some issues from time to time. Hopefully won't affect the outcome. Unable to modify the viewport meta tag for the site. The website is a preexisting large site that was ...

I would like my division to split into two halves, each with a width of 50%, and be aligned next to each other using fxLayout

<div fxLayout="row" fxLayoutAlign="space-between" style="background-color: blue;"> <div fxLayout="column" style="width: 50%;">1stOne </div> <div fxLayout="column" styl ...

Wrapper Div at the Center

I'm currently working on aligning my webpage in the center using the following CSS: .wrapper { display: flex; align-items: stretch; background: #fafafa; /*max-width: 1520px; */ box-shadow: 1px 1px 12px rgba(0, 0, 0, 0.1); text ...

Steps to create a clickable button wrapper label in React

Contained within the components below: <CheckboxGroupLabel htmlFor={option.label}> <FormCheckbox onClick={() => onChange} key={option.label} defaultChecked={defaultChecked} {...rest} /> {option.value} ...

Mastering CSS: Optimizing Div Placement Across Sections

I am currently working on developing a sleek and modern landing page with multiple sections, each designed to catch the eye. This style is all the rage at the moment, featuring large headers, ample padding, bold text, and a visually appealing divider betwe ...

Remove the excess white space surrounding the header background image on the website above the fold

How do I eliminate the white spaces on the left, right, and top of my background image that covers the header area above the fold on my webpage? I am currently testing in Google Chrome and using VS Code as my editor. html, body { width: 100%; height: ...

Add a fresh column in the table that includes modified values from an existing column, affected by a multiplication factor provided through a text input

I'm currently working on a Laravel website where I have a pricing table sourced from a database. The Retail Price column in this table serves as the base for calculating and populating a Discount Price column using a multiplier specified in a text inp ...