Arrange components with minimal spacing

I am currently working on a design that requires a perfectly aligned table using divs. Here is what I have done so far:

My goal is to have the time section placed on the left side of the entire row, while keeping the text right-aligned to avoid creating any spacing discrepancies. Here is an example of what I'm trying to achieve:

I have experimented with text-align: right;, direction: rtl, and adding more div elements, but unfortunately, nothing seems to be work as intended.

Here is the relevant HTML code:

<div class="container-fluid">
    <div class="row">
        <div class="header">
            <h1>EVENTS SCHEDULE</h1>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-2"></div>

        <div class="col-lg-8 date">
            <h4>Thursday, January 26th</h4>
        </div>

        <div class="col-lg-2"></div>
    </div>

    <div class="row">
        <div class="col-lg-2"></div>

        <div class="col-lg-8 event">
            <span class="event-time"> 1:00 PM</span>

            <h5 class="event-title">Special Olympics Unified Snowboarding Final</h5>
            <dd>SLOPESTYLE</dd>
        </div>

        <div class="col-lg-2"></div>
    </div>

Below is the relevant CSS code:

.date {
    background: rgba(26, 26, 26, 1);
    color: #fff;
    padding-left: 20px;
}

.event {
    color:#fff;
    background:rgba(0, 0, 0, 0.4);
    padding-top:10px;
    padding-bottom:10px;
}

.event-time {
    font-size:20px;
    font-family:"Arial", Arial, sans-serif;
    direction:rtl;
}

.event-title {
    text-align:left;
    line-height:.5em;
    font-size:20px;
    font-family:"Arial", Arial, sans-serif;
    display:inline-block;
    padding-left:80px;
}

.event dd {
    display:block;
    font-size:12px;
    font-family:"Verdana", Verdana, sans-serif;
    padding-left:150px;
}

Answer №1

If you're utilizing bootstrap classes, consider using smaller classes for better alignment on screens that may not be large enough.

Swap out col-lg-8 with col-sm- or col-md- to achieve the desired result:

    <div class="col-md-8 date">
        <h4>Thursday, January 26th</h4>
    </div>

    <div class="col-md-2"></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

Personalized designing of each letter

Is there a way to style numbers without using something like <span></span>? I'm looking for a clean way to do this for each sign. Attached is an example showing a "flip clock" effect that I would like to achieve. I have come across plugi ...

What is the best way to create a navigation link in PHP along with forms?

If the login credentials are correct, I will be directed to the member page. If not, I should remain on the same page. I am struggling with how to create a link to another page. I have come across some suggestions involving headers, but I am still unsure o ...

The React Material UI table is having trouble stretching to fill the space

Currently, I am experimenting with developing my own virtualization technique using a different approach than react-virtualized. However, I am encountering difficulties when it comes to styling. I have come across an issue where the material table in the ...

Adjusting the dimensions of the central container

Does anyone have suggestions on how to resize the middle red container when the window is resized, considering the fixed-width black containers on the left and right? I am aware that this can be achieved using jQuery by calculating the window width and a ...

Decrease the gap between rows in CSS Grid

I'm struggling to minimize the space between the rows. I've attempted adjusting margins and paddings to 0, but nothing seems to be working effectively. Displaying desktop view on the left and mobile view on the right side. .content{ margi ...

Using Twitter Bootstrap and jQuery UI modal within an mvc4 framework

I successfully integrated jQuery UI scripts for modal and datepicker into the generic MVC4 template view. However, when I tried to include Twitter Bootstrap layout as well, the datepicker and modal elements were not displaying properly. Additionally, I enc ...

Is it possible to achieve a smooth transition to the right using CSS

I'm attempting to create a sliding box effect from left to right using only transitions, similar to this: #box { width: 150px; height: 150px; background: red; position:absolute; transition: all 2s ease-out; right:auto; } .active{ bac ...

Disable checkboxes upon page initialization

I am working with a form that includes checkboxes. Whenever the page loads, clicking on the checkboxes automatically checks them. However, I am looking for a solution where the checkboxes are disabled or not clickable during the page load process. Once th ...

Adjust the size of col-lg-3

Is there a way to adjust the size of my col-lg based on different screen resolutions? I'm looking for a solution that can change the size of col-lg depending on the screen resolution. For example: .col-lg-3 { /* styles for screens with 1366x768p ...

What are the best ways to position elements within a div?

In my small information div, I am looking to align the content on the right side. Specifically, 065 31 323 323, <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a5d4c4c1c0cbdfc4e5c2c8c4ccc98bc6cac8">[email protected]</ ...

Combining various array values into a single key in JSON格式

Issue: I am working on a sign-up form for new users using HTML. The goal is to store multiple arrays (each containing "username: username, password: password, topScore: 0) within one JSON key ("user" key). However, the current functionality only allows f ...

The CSS class name is not having any impact on the React.js components

Struggling with CSS integration in ReactJS? That's the issue I've been facing while working on a project involving Rails and ReactJS. Despite implementing styles in my JSX files, nothing seems to change visually. Take a look at what my App.jsx fi ...

How can I create numerous HTML containers using Javascript?

I've been learning from this tutorial: Instead of just displaying the last database object, I want to display all of them. I have tried outputting the database contents and it's working fine. Now, I just need to adjust the HTML. I attempted to ...

What causes the position: sticky; property to fail in React implementations?

Currently, I am facing a challenge in making two sidebars sticky so that they will follow as the user scrolls until they reach the bottom of the page. In my current editing project, this implementation seems to be more complex compared to other programs w ...

``I am having trouble getting the Bootstrap carousel to start

I am having trouble getting the Bootstrap Carousel to function as expected. Despite including all the necessary code, such as initializing the carousel in jQuery.ready, the images are stacking on top of each other with navigation arrows below them instea ...

A comprehensive guide to effectively formatting Recharts in React: addressing alignment and size management!

While attempting to style two graphs as floating cards, I am encountering difficulties in controlling the sizing and centering of the graphs. Specifically, I am having trouble with the pie chart in this example. To address this issue, I am passing paramete ...

Pressing the reset button on the search box triggers a JQuery and HTML function

I am new to this, so bear with me. I've simplified my styling for easy pasting here, but the concepts still apply. I have a list of items, a working search field, and functioning filter buttons. What I want is for the filter buttons to reset to &apos ...

Create a path on the Google Map that follows the designated route

I am looking for a solution similar to one found here: Sample However, I have been unable to find a suitable solution anywhere. The main issue is being able to follow the route in order to draw a line between two points. Can anyone provide guidance on ho ...

Is the rotate() method in SVG supported on web browsers when passing in additional parameters like angle, centerX, and centerY similar to the CSS rotate

I have recently learned about a rotate transform that allows for rotating around a specified center point using the `rotate(angle, centerX, centerY)` method. However, I have noticed that this method does not seem to work when applied via CSS. Interestingl ...

What is the best way to add data from an array to a DOM element in the same order it was retrieved from Firebase?

Utilizing Google Firebase Firestore for data storage and the Open Movie Database (OMD) in combination with Axios to retrieve movie information. I am currently developing a website that allows users to add movies to collections. On the collections page, al ...