The alignment of rows and columns is not proper

I have been using bootstrap and encountering an issue with aligning rows containing 2 columns each. The alignment is not appearing as desired. What I want: https://i.sstatic.net/OoIiB.jpg

However, what I am getting is different: https://i.sstatic.net/FpI3B.jpg

I have spent over an hour trying to fix this but without success. Can someone please help me identify what's wrong here?

Below is the CSS related to this:

    .container {
  text-align: center;
  width: 80%;
}

/* Other CSS classes and properties follow... */

If you wish to view the codepen for a better understanding, click on this link - codepen. I have updated the image in the link to showcase the specific error where each row consists of an image and text on opposite sides causing misalignment.

Answer №1

When modifying col- divs, it's best to avoid changing their styles directly. Instead, create additional blocks inside them to achieve your desired layout. Keep in mind that the col- class comes with built-in padding.

You could try something like this:

<div class="row">
    <div class="col-lg-6">
    <div class="text-left">
      <div class="bordered-box">
        <img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
      </div>
    </div>
    </div>
    <div class="col-lg-6">
    <p>EASY TO UNDERSTAND<br><span class="spanf">Optimize Your Product & Category<br> Performance</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
    <button>Join Now</button></p></div>
</div>

Add style to bordered-box:

.bordered-box{
  display:inline-block;
  border:3px solid #46ab86;;
}

Check out the jsfiddle for a visual representation.

Answer №2

It is essential to ensure the correct usage of columns to avoid overriding your styling. The framework is designed in a way that minimizes the need for excessive CSS.

A key point to remember is that each row should be enclosed within its own container with the class row to maintain proper structure and alignment.

Avoid unnecessary styling as Bootstrap's column classes handle this effectively on their own.

Below is a straightforward example demonstrating the use of Bootstrap to align rows and position text on either side of the page:

Example:

<div class="row">
    <div class="col-md-6"><p>Your first row text item, left aligned by default.</p></div>
    <div class="col-md-6"><img src="your-image-file.jpg" class="img-responsive" alt="dont-forget-your-alt" /></div>
</div>
<div class="row">
    <div class="col-md-6"><img src="your-second-image-file.jpg" class="img-responsive" alt="really-dont-forget-your-alt" /></div>
    <div class="col-md-6 text-right"><p>Your second row text item, which needs to be right aligned by adding the class to the p tag.</p></div>
</div>
etc...

Answer №3

Here is an example of styling in CSS:

.right{ float:right; margin-right:10px;}

and in HTML:

        <div class="row">
        <div class="col-lg-6 imgleft"> <img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph"> </div>
        <div class="col-lg-6 right">
            <p>ECOMMERCE FOCUS
                <br><span class="spanf">Decision Focused Dashboards To<br> Supercharge Your Ecommerce Business</span>
                <br> There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.
                <br>
                <button>Join Now</button>
            </p>
        </div>
    </div>

Check out this JSFiddle link for a live demo.

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

Display data from additional tables within a loop

Within my database, I have organized information into 3 tables: train_information: +----------+-----------------+------------------+ | train_id | number_of_axles | number_of_bogies | +----------+-----------------+------------------+ | 1 | ...

Exploring the position property in CSS

Seeking assistance as a CSS beginner. Currently working on a project where I have managed to position container_main right next to container_menu, utilizing the remaining screen space by assigning them relative and fixed positions, respectively. container ...

What is the best way to extract table data with Selenium in Python?

Is there a way to simplify the HTML table source below for easier reading with selenium in python? <div class="general_table"> <div class="general_s"> <div class="general_text1">Name</div> <div class="gener ...

Ensure that the flex items are utilizing the full height of the parent when the flex-direction property is set to row

I'm currently working on a layout with 3 flex items in a flex container, each having equal height and width. While I've managed to achieve equal width for all 3 items, there's an issue with the first item. It contains a div (.images) that se ...

PHP and JQuery not working together to update database

Essentially, I am trying to update the status based on the unique id. Despite no errors being thrown, the status remains unchanged. index.php $(document).ready(function() { $('.seatCharts-seat').click(function(){ var id = jQuery(th ...

Retrieve information from the existing URL and utilize it as a parameter in an ajax request

Currently, I am working on a website with only one HTML page. The main functionality involves fetching the URL to extract an ID and then sending it to an API using an AJAX call. Upon success, the data related to the extracted ID is displayed on the page. H ...

How can I apply specific styling to certain cells within a table?

Is there a way to apply styles specifically to certain table headers in an HTML table without altering the HTML or introducing JavaScript? I need to target only 4 out of the total 8 table headers. To see the code and example for this question, visit: http ...

Tips on incorporating inline CSS within master pages

I am facing a dilemma with my master page that includes an external CSS file in the header. While most of the pages have the same height, only one page needs to be longer. Instead of creating a new master page or modifying the existing CSS file entirely, ...

Scrolling to a specific anchor in a React webpage when the URL is opened in

Imagine having a component "Post" that contains multiple components "Comment". How can we make the application automatically scroll down to a specific comment when entering a URL like this: /post/:postId/#commentId The route for postId /post/:postId is a ...

Use the value in the form to search the database for two specific values

I have scoured through various resources and found this question which seems to be similar to my current issue. However, I have not been able to find a solution that works for me. The form on our website allows users to create a list of questions from a la ...

What is the best method to transfer a div from one container div to another using jQuery?

I need some assistance with moving a div from one container to another using jQuery's sortable API. I've included the code within the jQuery ready function, but it doesn't seem to be working as expected. Here is the snippet of code I have a ...

Upgrade ngf-select to work with Angular 8 versions

Currently in the process of transitioning from AngularJS to Angular 8. Looking for guidance on how to update the following code snippet for Angular 8: <button class="other-button contactUsSpecific" type="button" (change)="contactCtrl.uploadFile ...

The beauty of Aurelia's scoped CSS

Embarking on my Aurelia journey, I find myself navigating through the vast world of web development with tools like nodejs, gulp, and more. The Aurelia CLI has made it convenient for me to set up a visually appealing Aurelia project in Visual Studio Code ...

Gap between two div elements side by side

Take a look at this simple code - fiddle here. The CSS is as follows: .subcontent > div { display: table-cell; } .orangebox { width: 55%; background-color: red; padding-top: 6px; } .bluebox { width: 43%; background-color: blue; ...

Combine the points of individual letters in Scrabble using jQuery

Hello, I'm currently working on creating a Scrabble game. My goal is to assign a value to each letter and then calculate the sum of these values when the input box changes. After some research, I was able to find information on how to add numbers on ...

Utilize identical code across various jQuery instances

I'm having trouble using the same script in two different places with another div. Below that, I need to use the same script for two different types of filters. I tried copying the script and changing the class name, but it's still not working. ...

Ways to elevate cells of different sizes?

I am new to web design and have created a small portfolio gallery. Each 'card' in the gallery includes an image, title, and caption. However, I'm facing an issue where some cards appear larger due to longer captions. I want each card to adju ...

Why is this dropdown list extending beyond the window?

Why is my dropdown list extending beyond the window? Despite trying to change the position of the dropdown list elements to fixed and top:0px, I am still facing this issue! I am unable to figure out why the list is going off the page. Your help in solvin ...

An alternative solution for object-fit in wkhtmltopdf

My current challenge involves exporting html pages to pdf using wkhtmltopdf. However, the object-fit I am utilizing to force my images into a square shape is not functioning as expected; instead of being cropped properly, the images are stretched to fit th ...

Error code "ER_BAD_FIELD_ERROR" was encountered with errno 1054 and sqlState "42S22" in index 0 while using MySQL with Angular and managing sessions

When I log in, the following code is executed: <div ng-include="'partials/navbar'"></div> <form name="form" ng-submit="login(form)"> <div> <input type="text" placeholder="Email" ...