Intermediate Push-Pull Training Classes

Hello, I am seeking advice on how to shift a sidebar to the left of the layout while maintaining the order of elements in the HTML. Specifically, I want the sidebar to appear as the 4th element, aligned to the top of the page. This adjustment is primarily for SEO purposes.

Below is the foundational markup that I am currently using:

<div class="row">
<div class="small-9 push-3 columns"> main content </div>
<div class="small-9 push-3 columns"> main content </div>
<div class="small-9 push-3 columns"> main content </div>
<div class="small-3 pull-9 columns end" > left sidebar </div> 
</div> 

At the moment, the sidebar appears in line with the third row, creating empty space in the first two rows. I expected the "end" attribute to float the sidebar to the left and up, but that's not the case.

If anyone can provide insight or a solution to this issue, I would greatly appreciate it.

Cheers, Justin

Answer №1

If you want to change the layout of your columns, consider replacing float: left; in your columns class with display: inline;. This will ensure that the columns are displayed next to each other without being pulled in any direction. You can also add some CSS to your end class to align the final column to the left.

The structure of the HTML remains the same, but the updated CSS will look like this:


.columns {
    position: relative;
    padding-left: 0.9375rem;
    padding-right: 0.9375rem;
    display: inline;
}

.end {
    float: left;
}

All other styling in your CSS should remain unchanged. You can see the result on Jsfiddle here: fiddle


I noticed that my code aligns all the divs on the same row, while yours aligned them beneath each other. If you prefer the second option where the last div is to the left and the first three are under it, please let me know so I can adjust the code accordingly.


Update

Based on the new requirement, I have made the following changes to the code:

Revised CSS:


.arange_to_left {
    float: left;
    width: 25%;
}
.arange_to_right {
    width: 70%;
    float: right;
}
.columns {
    position: relative;
    padding-left: 0.9375rem;
    padding-right: 0.9375rem;
    padding-bottom: 10px;
}
.row {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
    margin-bottom: 0;
    max-width: 62.5rem;
}

Updated HTML (simplified):

<div class="row">
    <div class="arange_to_right">
        <div class="small-9 push-3 columns">1. Something</div>
        <div class="small-9  push-3 columns">2. Something else</div>
        <div class="small-9  push-3 columns">3. Anything else</div>
    </div>
    <div class="arange_to_left small-3 pull-9 columns">SIDE BAR</div>
</div>

View the updated layout on this fiddle: result

Please note that there is a gap between the left and right divs for potential borders or padding. Feel free to adjust the percentages as needed.

The row div may not expand to contain its floated children. To address this, I have provided an example in this demonstration with additional CSS for the end class.

.end {
    clear: both;
}

Answer №2

Could this be the solution you've been looking for? Utilizing only css and html, I may have created what you need. Do you prefer one left-side-bar or multiple left-side-bars per row? The first example showcases the per row format, while the second displays a single, left-aligned sidebar.

Per Row Example: http://jsfiddle.net/75WA9/

Single Left-Side-Bar Example: http://jsfiddle.net/UPpDS/

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

When resizing the browser or changing resolution, one div may cover another div

After generating the HTML on my ASP.NET page, everything looks good initially. However, I noticed that when I adjust the screen resolution or reduce the browser size, the image in the logoplace div starts to overlap. It appears to be an issue with absolute ...

Animated scrolling does not function properly with external links that are fully qualified

Currently, I am working on the website julebord.bedriftsdesign.no and have added animated scroll functionality to this page: However, I have encountered a problem. The animated scroll works perfectly fine when using internal anchor links like (#myanchor). ...

Enhance image with Fancybox on mouse click

I need to display several images in the content area of a page, and when a user clicks on an image, it should enlarge using fancybox. If an image is large, the user should be able to click on it to view an enlarged version in a fancy box. Both the thumbn ...

Best practice for encapsulating property expressions in Angular templates

Repeating expression In my Angular 6 component template, I have the a && (b || c) expression repeated 3 times. I am looking for a way to abstract it instead of duplicating the code. parent.component.html <component [prop1]="1" [prop2]="a ...

Whenever a modal is generated along with its overlay, the overlay fails to cover the entire document

With that being said, the recurring issue that always arises is as follows: -modal and overlay appears, -user scrolls down -user can click elements under the overlay How can this be fixed? The primary concern right now is with the overlay. The CSS cod ...

The table is overflowing its parent element by exceeding 100% width. How can this issue be resolved using only CSS?

My root div has a width of 100% and I need to ensure that all children do not overlap (overflow:hidden) or exceed the 100% width. While this works well with inner <div>s, using <table>s often causes the table to extend beyond the parent 100% d ...

selenium for extracting data from span class tag

After trying to click the button with the text "details," I encountered a "no element found" error. It seems like the tag is within a child class... span _ngcontent-tbi-c3="" class="ng-star-inserted">Details</span Below is my Python code snippe ...

Copying information from one website and transferring it to another website

To verify a user's authentication, I first collect their username and check it against the database to determine their authentication method. Depending on the authentication method, I then provide them with the appropriate login window to access their ...

Path of the HTML5 database in Blackberry WebWorks

When referencing the Blackberry WebWorks API guide for HTML5 Database, I came across a crucial note: Note: For 5.x devices, an SD card is a necessary storage method for databases. To initialize a database, you can use this code snippet: db = window.open ...

Customizing input behavior - Managing the value and onChange event of a controlled <input /> element in VueJS

Switching over from React, I am familiar with the idea of taking "control" of an html element's value and events. Now, I am exploring how to achieve a similar concept in VueJS. Here is what I have so far: <input :value="foo" @input="changeFoo" pa ...

Transform this text into a unique format: _"text

I am developing a website for a small elementary school, allowing teachers to create new posts for parents of students. I want to keep the webpage design simple and user-friendly, but I'm facing an issue with text formatting. Currently, all written te ...

Using Bootstrap, creating a full-height body with multiple scrollable divs

Struggling to replicate a HTML layout similar to the one shown in Figure 1 using bootstrap. Figure 1 Despite numerous attempts, I am still unable to fully achieve the layout using bootstrap's row and column classes. If anyone can offer guidance, it ...

Manipulating layout with html5 VIDEO controls

I'm having an issue with the HTML5 video element. When I don't use "Controls," it displays with the border-radius as I specified. https://i.stack.imgur.com/KMEeJ.png However, when I add controls (which I need), an ugly border appears and overri ...

Firefox seems to be the only browser where window.parent.document is functioning properly, as it is not working

Is there a way to update the value of a text box on the main page from an iframe? Currently, I have code that works in Firefox but not in Internet Explorer or Chrome. The "main.html" and "frame.html" files are located in the same directory. Any suggestions ...

Ways to activate the date input field and reformat it for smooth insertion or selection in mysqli

I would like to enable the input of dates in UK format - DD/MM/YYYY on an HTML form. Before any PHP code is executed, such as queries (e.g. select, insert, etc.), I want PHP to convert the entered date from DD/MM/YYYY to YYYY-MM-DD. HTML <div class="f ...

Is there a way to accomplish this using Bootstrap?

Hello there! I have a piece of code that is working with both bootstrap and Pixedelic camera. Here it is: <section id="slider" class="container-fluid"> <div class="row fluid"> <div id="camera_wrap_1"> <div data-src="conten ...

Can using display: none impact the SEO of a website's navigation menu?

Is there a difference in SEO impact between using display:none with CSS and using display:none with jQuery for menus? Appreciate the insights! ...

Locate a div element based on its inner text and then apply a specific

I am looking to target a specific div based on its inner text, and then add a class to it. How can I achieve this? For example, consider the following input: <div>First</div> <div>Second</div> <div>Third</div> The desi ...

Managing multiple dropdown menus in PHP when dealing with Select options

In the given script, I am attempting to manage the selection between a dropdown option and the value of a text field: <script> function check() { var dropdown = document.getElementById("OpType"); var current_value = dropdown.options[dropdown ...

Tips on showing the prior user entry in addition to the latest input

I'm a beginner in HTML and I'm attempting to create a script that will show user input back to the user. The issue I'm facing is that each new input overrides the previous one, but I want to display all user inputs. How can I achieve this us ...