Adaptable CSS column layout

I'm in the process of setting up a two-column layout. The main content column houses the blog card, while the secondary column I'm attempting to position at the top right corner.

Check out this link for the blog card.

This is the Bootstrap layout code snippet I've been using:

<main role="main" class="container">
  <div class="row">
    <div class="col-md-8">
      <div class="blog-card">
        <div class="meta">
          <div class="photo" style="background-image: url({{ post.featured_image }})"></div>
          <ul class="details">
            <li class="author"><a href="#">John Doe</a></li>
            <li class="date">Aug. 24, 2015</li>
            <li class="tags">
              <ul>
                <li><a href="#">Learn</a></li>
                <li><a href="#">Code</a></li>
                <li><a href="#">HTML</a></li>
                <li><a href="#">CSS</a></li>
              </ul>
            </li>
          </ul>
        </div>
        <div class="description">
          <h1>{{post.title}}</h1>
          <h2>Opening a door to the future</h2>
          <p>{{post.summary}}</p>
          <p class="read-more">
            <a href="{{ url_for('blog.show_post', slug=post.slug) }}">Read More</a>
          </p>
        </div>
      </div>
    </div>
    {% endfor %}
    <div class="col-md-4">
      <div class="content-section">
        <h3>Our Sidebar</h3>
        <p class='text-muted'>
          You can put any information here you'd like.
          <ul class="list-group">
            <li class="list-group-item list-group-item-light">Latest Posts</li>
            <li class="list-group-item list-group-item-light">Announcements</li>
            <li class="list-group-item list-group-item-light">Calendars</li>
            <li class="list-group-item list-group-item-light">etc</li>
          </ul>
        </p>
      </div>
    </div>
  </div>
</main>

In the desktop view, the content in col-md-4 does not stick to the right, instead, it appears at the bottom of the card. Despite trying various methods, the sidebar remains fixed to the last post rather than appearing at the top right with the first post. I am fetching data from an API and utilizing the blog card to showcase posts from the CMS.

Answer №1

To ensure your content is properly formatted within the main tag, utilize the container class. This class includes predefined max-width and padding values for the left and right sides of the content area. If you prefer your content to span the full width of the page, consider using the container-fluid class instead.

<main role="main" class="container-fluid">
  <div class="row">
    <div class="col-md-8" style="border:solid 1px red">
      {% blog %}{% card html }
    </div>
    <div class="col-md-4" style="border:solid 1px red">
      <div class="content-section">
        <h3>Our Sidebar</h3>
        <p class='text-muted'>
          You can place any desired information in this section.
          <ul class="list-group">
            <li class="list-group-item list-group-item-light">Latest Posts</li>
            <li class="list-group-item list-group-item-light">Announcements</li>
            <li class="list-group-item list-group-item-light">Calendars</li>
            <li class="list-group-item list-group-item-light">etc</li>
          </ul>
        </p>
      </div>
    </div>
  </div>
</main>`

Answer №2

After some trial and error, I managed to make the sidebar display only on specific screen sizes. Although this caused my blog card layout to become slightly messy, I am satisfied with the end result.

Instead of relying on columns, I found that using media queries was the key:

@media only screen and (min-width: 1020px) and (max-width: 3000px)

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

"Download and set up the http_parser gem on your Windows operating

Working on a Symfony project and Bootstrap 4, I am trying to use the source bootstrap. To do this, I require Ruby and all bundles. Firstly, when I run: bundler install, I encounter an error during installation of http_parser.rb (0.6.0). Next, I try runni ...

Connecting a saved link to a picture located in another document using HTML

Hey there! I'm currently working on including an image with the following code: <p class="b1"> <img id="cakes" src="~/images/cakesBanner.png" alt="cakes"> </p> In a different file, I have the following code: <div class="nav ...

What is the best way to declare a variable in order to apply a custom background color to a

I am having trouble getting the conditional background color to apply to the textbox when I set the variable columnstyle. Here is the snippet of HTML code: var columnstyle = "text-align:center;vertical-align:central;background-color:#FFBF00"; ...

Problem with animated scrolling in Jquery

Currently, I am working on a function that aims to smoothly scroll the web to a specific div each time a user scrolls "into" a container div. You can get a better idea of what I mean by looking at my JSFiddle. Everything works perfectly when the user scro ...

Divide table rows in html without a header into two equal parts, with 50% on the left side

I am trying to format 20 rows in a standard html table without any headers. The current setup looks like this: current situation <table> <tbody> <tr> <td>1</td> </tr> <tr> ...

Adjust the dimensions of the main svg while keeping the proportions of all elements contained within

Is there a way to adjust the size of the outermost svg while keeping the size of the elements inside the svg unchanged? I've searched online but couldn't find a solution to this specific issue. To provide context and avoid the x-y problem, let ...

Learn how to fetch user-selected options in Node.js and display the corresponding file contents in a textarea after submission

Hello, I am new to Node.js so please be patient with me. I am struggling to figure out how to retrieve the selected option from a drop-down list after a user submits it and then perform an action based on that choice. Here is an example of what I have in m ...

Enhanced customization of material-ui styles

After exploring various resources on styling overrides, I encountered a unique challenge. I am engaged in crafting styled material-ui components and integrating them across different sections of my application. My objective is to enable the customization o ...

What could be causing the malfunction of this setTimeout function? Another related question to consider

I recently implemented a script on one of my pages, but I noticed that the setTimeout function doesn't seem to be triggering. Currently, it's just set up to display an alert as a test. I suspect that the issue might be related to a meta refresh t ...

I am facing issues with my submit buttons as they are not functioning

Once I hit the submit buttons, there seems to be an issue with redirecting to another page. Could anyone assist in identifying the error within this code and why my buttons "typ1" and "cod" are not redirecting to the specified location? <?php inc ...

Issue with badge counter not functioning properly on Bootstrap button

My Bootstrap button has a badge counter that indicates how many items are linked to it. <a href="{{ route('events.index', ['group_id' => $group->id])}}" class="btn btn-sm btn-primary">Events <span class="badge badge-ligh ...

"Implementing a dynamic search for IMG SRC using ng-src in AngularJS: a step-by-step

I am encountering an issue with setting the source of an image based on a variable that may initially be null. When I set the source to include the path and the variable followed by PNG, I get an error because the variable is null at the beginning. How can ...

CSS rule for targeting an element that does not have any child elements

I have a variety of different elements that are structured similarly to the following.. <div id="hi"> <div class="head"> </div> <div class="footer"> </div> </div> ..however, some of these elements do no ...

Retrieve the chosen option from the drop-down menu

Can anyone assist me in extracting the selected value from a combo box and then displaying it? Below is a snippet of code that demonstrates what I have attempted so far. <label class="col-sm-4 control-label">Issue Type:</label> <div> ...

Exploring Vue's data binding with both familiar and mysterious input values

How can I model an object in Vue that contains both known and unknown values? The quantity is unknown, but the type is known. I need to present user inputs for each type, where the user enters the quantity. How should I approach this? data() { retur ...

Animate the sliding up of divs using Jquery SlideToggle

Is there a way to make this perfect example slide up instead of pushing the 'navs' down? View Example Here Currently, it reveals from top to bottom (pushing the menu down), but I want it to slide up and push the navs up when clicked. The fiddl ...

class automatically receives an unwanted display: none attribute

After I added a copy link inside my panel and clicked to open it, an automatic display:none was triggered. To fix this issue in my jQuery code, I included the line: showme.style.display = "none";. This allowed me to open the panel successfully, but now I& ...

Discovering the quantity of identical elements within a JavaScript array

Looking for some assistance in solving a JavaScript problem as I am relatively new to the language: I have an array and I need help in determining the count of identical values. Below is my array: var arr = ["red", "blue", "green", "red", "red", "gray"] ...

Encountering a problem with loading the stylesheet

I keep encountering a 404 error when trying to load the CSS in my web application. The HTML content looks like this: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>PSL Inter App</title> <meta nam ...

What are the steps for effectively utilizing the EmChart to achieve precise font sizes in ems?

Can you explain the intended use of this chart and instructions for how to utilize it? ...