Move all items in the div to the right/left using Bootstrap

Recently, I've been working on making my webpage responsive. I included Bootstrap and organized my content into two divs side by side within a fluid container.

Despite my efforts to use "pull-right" and "float-right" classes on the left buttons, and "pull-left" and "float-left" classes on the right image, they are not aligning as expected. Am I using the correct classes?

Here's a snippet of the HTML code:

<div class="container-fluid">
    <div class="row">
            <div class="col-md-4 right" style="float-right">
                <div class="h1padding"></div>
                <a class = "h1" style="float-right" href="" id="introID"><b>INTRO</b></a>
                <!-- more content here -->
            </div>
            <div class="col-md-8 left" style="float-left">
                <img src = "assets/images/white-leaf-bg.jpg" id="frame"/>
            </div>
    </div>
</div>

And here's a snippet of the CSS code:

a:link, a:visited {
    font-family: 'Gotham';
    text-align: right;
    <!-- more styles here -->
}

<!-- more CSS styles here -->

Currently, the image appears on the left, and I still need to figure out how to vertically center it. However, the buttons remain on the left side.

Any help or advice is greatly appreciated. Thank you!

Answer №1

Your formatting is incorrect.

<div class="col-md-8 left" style="float-left">
    <img src = "assets/images/white-leaf-bg.jpg" id="frame"/>
</div>

Corrected version:

<div class="col-md-8 left" style="float:left;">
    <img src = "assets/images/white-leaf-bg.jpg" id="frame"/>
</div>

Alternatively, you can use Bootstrap's classes:

<div class="col-md-8 pull-left">
    <img src = "assets/images/white-leaf-bg.jpg" id="frame"/>
</div>

To align your content to the right/left, consider the inline elements which are affected by the text-align CSS property:

<div class="col-md-8 pull-left text-right">
    <img src = "assets/images/white-leaf-bg.jpg" id="frame"/>
</div>

Check out the examples using Bootstrap in the external Codepen link below:

Answer №2

It's unnecessary to align a <div> that is initially positioned in a row.

There are alternative methods for achieving this, but they are not recommended and do not align with the principles of bootstrap.

The best approach is to simply add classes to your HTML elements.

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
  <div class="row">
    <div class="col-md-8" style="border:3px solid red">
      <img src="https://dncache-mauganscorp.netdna-ssl.com/thumbseg/23/23636-bigthumbnail.jpg" id="frame" />
    </div>
    <div class="col-md-4" style="border:3px solid blue">
      <div class="h1padding"></div>
      <a class="h1" style="float-right" href="" id="introID"><b>INTRO</b></a>

      <div class="h1padding"></div>
      <a class="h1" href="" id="OnSuerfaceID"><b>ON THE</b> <span class="light">SURFACE</span></a>

      <div class="h1padding"></div>
      <a class="h1" href="" id="FromOilID"><b>FROM</b> <span class="light">ORE TO OIL</span></a>

      <div class="h1padding"></div>
      <a class="h1" href="" id="EnvImpactID"><b>ENVIRONMENTAL</b> <span class="light">CARE</span></a>

      <div class="h1padding"></div>
      <a class="h1" href="" id="MoreThanGasID"><b>MUCH MORE THAN</b> <span class="light">GASOLINE</span></a>

      <div class="h1padding"></div>
      <a class="h1" href="" id="OneMoreID"><b>ONE MORE</b> <span class="light">THING</span></a>
      <br><br>
      <div class="h1padding"></div>
      <div class="h1padding"></div>
    </div>

  </div>
</div>

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

Having trouble keeping the HTML text centered within the div on a responsive layout

Having an issue with keeping text centered in the middle of a div that overlaps an image. It looks fine on desktop but when I try to make it mobile-friendly, things go haywire. I believe the problem lies in using fixed heights for the div, as setting heigh ...

Using CSS to showcase div elements with varying dimensions

How can I arrange divs with varying heights to be positioned close together, regardless of their height, and with a specific margin similar to buildings? I am aiming for a layout like the one on this website . I tried using float:left but it only float ...

Designing a webpage using CSS

the design I'm aiming for I am attempting to create a header layout as depicted in the image below using HTML and CSS. I have managed to place the logo in the center, but I am facing difficulties in aligning the business list to the corner. I have tri ...

Optimal Procedure for New Users Form (Jade / Angular) in HTML

I'm currently working on integrating a form into my app for users to create tasks. This form should only appear the first time a user attempts to create a task. As someone who is not very experienced with frontend development, I find myself wondering ...

Interactive div with dynamically generated click event

I need to add an onclick event to a button that is being generated dynamically via ajax. How can I achieve this? This is the code responsible for generating the content. When we click on an item, I want a popup window to appear. function retrieveTableDat ...

I require assistance in developing a mouseover image link that conceals the top image and unveils a bottom image that scrolls vertically in the exact same area as the top

I am trying to achieve a similar effect as shown on: this website I require assistance in creating a mouseover image link that hides the top image and reveals a bottom image that scrolls vertically within the same space as the top image. The long vertica ...

Experience the dynamic expansion of a droppable div as you elegantly drop an element within

When the questions "question1" and "question2" are dragged into "questionslots," I want the "questionSlots" div to expand its size dynamically when the second question is dropped into it. This means that both questions should be accommodated and visible wi ...

displaying a pair of distinct elements using React techniques

I need help adding a react sticky header to my stepper component. When I try to render both components together, I encounter an error. To troubleshoot, I decided to render them separately. Surprisingly, when rendering separately, I do not get the "store is ...

Here is a guide on how to ensure that the div elements automatically fill the available space

Looking at this html page: Check out the jsFidlle Demo here I am aiming to have the boxes fill up the space effortlessly, each with equal width but varying heights. This is similar to the layout in Google Keep notes ...

Tips on updating primeng Panel Menu appearance with scss

I'm looking to customize the color of my panel menu to black. Below is the HTML code I am using. <p-panelMenu styleClass="font-bold text-xs m-0 w-11" [model]="items" [multiple]='false'></p-panelMenu> ...

Is there a way to prevent the body content of this modal from overflowing outside of the modal box? I want to ensure that the text remains contained within the modal

Recently in my Angular 7 application, we integrated Bootstrap 4 for styling. However, we encountered an issue where the text inside a modal spills out of the box. How can we modify the CSS to ensure that the content remains responsive and contained within ...

Achieve perfect alignment of Bootstrap checkboxes

Is there a way to vertically align checkboxes in a column with their labels? My goal is to have these elements centered on the page, but I want the checkboxes themselves to be aligned vertically. <div class="row"> <div class="span12 paginatio ...

Tips on extracting JSON information in JavaScript when the key name is unspecified

I have a challenge in parsing JSON data where the property name is unknown. Below is a snippet of my code, and I need your help in figuring out how to retrieve all data with an unknown property. datas.data.videoGroup.past, then utilize a loop $.each(data ...

"Taking a break" and indulging in Sass

When transferring Sass classes from another project, I wanted to create a wrapper to contain these styles locally. Here is how my wrapper is currently set up: .my-wrapper { @include "framework-main" } Initially, everything seemed fine. However, I soo ...

What is causing the 'transitionend' event to trigger multiple times?

Currently, I'm honing my JavaScript skills by taking on the 30 days of JavaScript challenge. I'm puzzled by why the 'transitioned' event is triggered twice in the code snippet below. My CSS only contains one property called transform, ...

Align an element to the right outside of its parent

I am facing an issue with my parent div and three children. I want one child to float left of the parent, one to be in the exact center of the parent, and one to float right of the parent. However, the floated right element is going outside of the parent d ...

Ways to create a vertically expandable full-screen design

I am currently working on designing a full-screen layout where the content adjusts based on the size of the footer. body { margin: 0; padding: 0; } .layout { height: 100vh; display: flex; flex-direction: column; background-color: yell ...

Arrange four divisions so that they are displayed in pairs on each row when the viewport width is smaller

I have a row of 4 div elements aligned horizontally from left to right. Each div takes up 25% of the screen width. I am looking for a solution to make them wrap when the user resizes the screen instead of overlapping each other. .MenuSett { margin-to ...

The custom component at the beginning of the MDX file in a Next.js project is not adhering to the

My nextjs project is running on the following versions: "@mdx-js/loader": "^2.1.5", "@mdx-js/react": "^2.1.5", "@next/mdx": "^12.1.6", "next": "^12.1.6", Within my project, I ...

Styling PHP Input Buttons with CSS

I'm facing an issue with styling the button on a working form. Even though I added CSS and declared the button class, it's not applying the styles. The CSS is defined at the top of the HTML file, and the PHP code is embedded within. Both classes ...