Arranging DIV elements with flexbox and CSS

I have a straightforward layout featuring a 3-column design that consists of a back button, a main content section, and a forward button:

<div class="container h100">
        <div class="row align-items-center h100">
            
            <div class="col-sm-2 align-self-center order-1" id="backbutton">
                <button>Back</button>
            </div>
        
            <div class="col-md-8 align-self-center align-self-stretch" id="main">
                <p>Main content</p>
            </div>
        
            <div class="col-sm-2 align-self-center order-1" id="backbutton">
                <button>Next</button>
            </div>
        </div>
</div>

display on a larger screen

If the screen is smaller (like a phone), I want the main content to be on top with the back and next buttons below it in one row (with back on the left and next on the right).

desired layout on a smaller screen

I've attempted using "order-1" and "order-12", but so far, no success. Any recommendations?

Answer №1

It is best to give this a try on your own. I understand the frustrations that can come with CSS (I've been there before and had a similar question ages ago).

.wrapper {
  display: flex;
  flex-flow: row nowrap;
}

@media screen and (max-width: 480px;){
  .wrapper{
    flex-flow: column;
  }
}

This should do the trick, but I suggest checking out Flexbox Froggy for more practice.

Answer №2

<html lang="en">
<head>
  <title>Web Page</title>
</head>
<style>
  #btn1 {
    float: left;
  }
  #btn2 {
    float: right;
  }
  #main {
    height: 300px;
    background-color: #ffe500;
  }
</style>
<body>
  <div id="main">
    main content
  </div>
  <div id="btn">
    <button id="btn1">Previous</button>
    <button id="btn2">Next</button>
  </div>
</body>
</html>

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

Incorporating HTML within PHP

I'm struggling with the following issue: after this, I end up with a blank page. Here is the code snippet in question: I am attempting to use HTML within PHP and then PHP again within HTML. The rest of the code is functioning correctly. If I replace & ...

Strange behavior observed while attempting to create a smooth CSS transition effect from the right side

Is there a way to create a hover effect in my navbar where a line appears from the bottom left and top right, without causing any size or alignment issues with the links? * { margin : 0; padding: 0; } nav{ background-color: black; width: 1200px; he ...

Is there a way to enable text selection on a jQuery draggable div?

I utilized jQuery to make a specific div draggable, but I've encountered an issue. Inside this draggable box, there is some important text that I need to be able to copy and paste. However, whenever I click on the box, it triggers the dragging action ...

Exploring the process of extracting/parsing HTML with Microdata

Hello, I am relatively new to the concept of Microdata. I currently have an HTML string that contains Microdata and I am interested in exploring the possibility of extracting the necessary information dynamically using Microdata with JavaScript or jQuery. ...

`Finding Solutions for jQuery and CSS Problems`

My jQuery slideDown/slideUp animation works smoothly in IE9 and Firefox, but is choppy in Chrome. When I remove the css file, the issue disappears, leading me to believe it is a Chrome and CSS interaction problem. Are there any tools available to help ide ...

CSS Switchable Style Feature

I am in need of some assistance with the navigation on my website. You can find the current code at this link: http://jsfiddle.net/Sharon_J/cf2bm0vs/ Currently, when you click on the 'Plus' sign, the submenus under that category are displayed bu ...

Is it possible to influence IE Browser Mode to switch to Compatibility mode?

As I was examining my website, I made an interesting discovery. It appears correctly in Internet Explorer 8 and 7 when I include the meta tag <meta http-equiv="X-UA-Compatible" content="IE=9">, but in IE 9 and 10, the display is incorrect. However, w ...

The Joys of Delayed Animation with jQuery Isotope

Has anyone successfully modified the CSS3 transitions in jquery Isotope to incorporate a delay for shuffling items, such as using "transition-delay: 0s, 1s;"? I am aiming for a specific shuffle direction - first left, then down - to create a more calculat ...

Gradient background overlaid with a blended SVG shape

Creating a full gradient background with a clipping mask can be tricky. I used an SVG to achieve the desired shape by cutting part of the background color, but now I'm facing a challenge with blending the colors seamlessly. I tried setting the SVG co ...

Troubleshooting the issue of Bootstrap 4 scrollspy failing to update active navbar items

I have been working on a Bootstrap 4.0 landing page and trying to implement ScrollSpy without success. The active menu items are not changing as expected. Here is the code snippet from index.html: <body> <!-- Navbar --> <nav id="main-nav" ...

Set Bootstrap column size to match a particular column

I am currently using BootStrap 4 and I am attempting to make a column's height equal to another column. Below is the code snippet I am working with: <div class="container" style="overflow:hidden"> <div class="row" style="overflow:hidden" ...

Is there a way I can detect a browser timeout and display a custom error message?

My webpage in classic asp contains a link to a local IP address, shown below: <a href="http://192.168.1.89">Link</a> When the local IP address is not available, the web browser eventually times out and shows its own error message. I ...

Display a div every 3 seconds with the help of jQuery

I am seeking a solution to display the second div (box2) every 3 seconds. Can anyone help me achieve this using jQuery? <div id="box1" style="background-color:#0000FF"> <h3>This is a heading in a div element</h3> <p>This ...

Tips for adjusting the font color of user-provided text within an input box using HTML and CSS

HTML code:- <p><input type="text" placeholder="Enter your username"></p> CSS code:- .main-header input { width: 90%; padding: 1rem; margin: 20px 0px; border: none; border-bottom: 4px solid #5f5fb0; ...

Loading information in a directive by utilizing promises in a service with AngularJS

Can anyone lend a hand? I've been struggling to solve this issue. I created a directive (see below) to display a pre-written ul-list on a page using html data fetched asynchronously from a database server. Both the Directive and The Service are funct ...

Is there a way to incorporate additional text into option text without compromising the existing values?

One challenge I'm facing is adding additional text to the options without changing their values upon selection. Would you be able to assist me with resolving this issue? I have come across the following HTML code: <select id="q_c_0_a_0_name"> ...

Why doesn't the z-index of child elements function properly when their fixed parents share the same z-index value?

I have utilized jsfiddle to replicate my problem. My goal is to position .top .inside above .bottom .inside. I am aware that z-index only functions within its respective position type, for example fixed and absolute do not share the same z-index level. How ...

Divs should be of consistent and adjustable height

I am in need of a layout with three columns: left column (with a red background) center column (with a yellow background) right column (with a black background) This is the HTML structure I have in mind: <div id="container"> <div id="left_ ...

The integration of Angular CLI with SCSS is no longer a separate process -

It seems like I might be overlooking something very straightforward here. After a fresh installation of angular-cli, I created a new website with SCSS. I input the SCSS in the global style.scss as well as some in a component SCSS file. However, when I se ...

excess spillage occurring within the table's td elements

Is there a way to apply the overflow property to a cell within a table? http://jsfiddle.net/e8Bxj/ table { width:100px; height:100px; } td.content { overflow:auto; } <table> <tr> <td>hmm</td> </tr& ...