Designing a component with Bootstrap-inspired flair

We are currently in the process of transitioning our ASPX CMS website to a new platform, and some of the retired pages will be hosted on a separate website under a subdomain. The new website will be utilizing Bootstrap 4.6, whereas our existing CMS site relies on custom CSS without any frameworks or libraries. As a result, I am now tasked with extracting various sections of the website and reconstructing them using Bootstrap.

One particular section I am working on is the 'Speakers' segment, but I have encountered some challenges that I believe are stemming from my current approach. I am attempting to replicate a design concept with a horizontal line for padding across the screen width.

Here is an example of what I am trying to achieve:

https://i.sstatic.net/CC5fy.png

And here is my current progress, along with the reasons why I am seeking assistance:

https://i.sstatic.net/aQGsE.png

Additionally, here is the HTML code I am currently using:

<div class="row pt-4 mt-1 pb-4">
        <div class="col-lg-10">
            <div class="container-fluid ceda-event-box pl-0 pb-5">
                <h2 class="mt-5 pr-1 pl-5 pt-4 bg-ceda-darkblue"><br></h2>
                <p><br></p>
            </div>
        </div>
    </div>

Furthermore, here are the CSS classes I am utilizing (mostly inherited from the existing site's CSS) to maintain consistency with the gradient grey color and SVG image:

.ceda-event-box::before {
    content: "";
    display: block;
    position: absolute;
    left: calc((100% - 100vw) / 2);
    right: 54px;
    top: 0px;
    bottom: 0;
}

.ceda-event-box::before {
    background: linear-gradient(64.15deg, #f3f3f3 50.52%, #bfbfbf 100%);
    z-index: -1;
}

... (CSS continues)

If you have any recommendations on better Bootstrap components or alternative approaches to construct this section, I would greatly appreciate any guidance or suggestions you can provide. Thank you!

Answer №1

To ensure proper alignment of the blue element with the grey background, consider setting the element to position: absolute and adjusting the top, left, and right properties accordingly. The key is to match the right property of the blue element with the one defining the grey background's position in relation to its elements, which is most likely .ceda-event-box::before. Both elements should be absolute and inherit relative properties from their closest parent for proper alignment.

:root {
  --top: 4px;
  --height: 98px;
}

// CSS code for styling the elements goes here
// ...

}
<div class="row pt-4 mt-1 pb-4">
        <div class="col-lg-10">
            <div class="container-fluid ceda-event-box pl-0 pb-5">
                <h2 class="mt-5 pr-1 pl-5 pt-4 bg-ceda-darkblue"></h2>
                <p><br></p>
            </div>
        </div>
    </div>

To align the bottom of the blue element with the bottom of the gradient ( .ceda-event-box::before), you can use the same bottom property for both elements. Including a 20% buffer for the bottom of the elements will demonstrate this alignment. Again, using CSS variables can help achieve this seamlessly.

:root {
  --top: 4px;
  --height: 98px;
  --bottom: 20%;
}

// More CSS styling for the elements can be added here
// ...

}
<div class="row pt-4 mt-1 pb-4">
  <div class="col-lg-10">
    <div class="container-fluid ceda-event-box pl-0 pb-5">
      <h2 class="mt-5 pr-1 pl-5 pt-4 bg-ceda-darkblue"></h2>
      <p><br></p>
    </div>
  </div>
</div>

Answer №2

I approached it from a different angle and made some modifications that I feel enhance it:

Here's the revised version specifically tailored for desktop/large screens... there's room for further adjustments and the CSS Classnames will be updated. https://i.sstatic.net/df94o.png HTML Code:

<div class="clearfix pb-4"></div>
    <div class="container-fluid float-left pl-0 pr-0 test-box mb-4">
        <div class="container-fluid float-right pt-4 test-box-title">
            <h2 class="b-heading-2 pt-4 pb-4">SPEAKERS</h2>
        </div>
        <div class="container-fluid float-right pr-0 m-0 bg-ceda-darkblue text-white test-box-dark">
            <p class="p-sm-2 p-lg-5">The Hon. Dominic Perrottet MP, Treasurer of NSW<br>
                Melinda Cilento, Chief Executive, CEDA</p>
        </div>
    </div>

CSS Code:

.test-box {
    width: 85% !important;
    background: linear-gradient(64.15deg, #f3f3f3 50.52%, #bfbfbf 100%);
    z-index: -1;
}

@media (max-width: 768px) {
    .test-box {
        width: 95% !important;
    }

    .test-box-title {
        max-width: 92% !important;
    }

    .test-box-dark {
        max-width: 90% !important;
    }
}

.test-box-title {
    max-width: 85% !important;
}

@media (min-width: 768px) {
    .test-box-title::before {
        content: "";
        display: block;
        width: 127px;
        height: 98px; 
        background-image: url("edited-base64");
        position: relative;
        top: 70px;
        right: 40px;
        background-repeat: no-repeat;
        float:right;
        right: 0%;
    }
}

.test-box-dark {
    max-width: 65%;
}

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

Div element remains fixed in width while zooming in

I'm encountering an issue with a centered div, where the width is set to 50% and the max-width is set to 100%. When I zoom in, the width remains constant but the height increases. Despite setting the max-width to 100%, why does this occur? And most im ...

The focusable attribute in SVG is malfunctioning

I've utilized the focusable attribute to ensure SVG elements receive focus within an HTML document. My goal is to navigate through SVG elements in the SVG tag using the TAB key, as indicated in this resource (http://www.w3.org/TR/SVGTiny12/interact.h ...

Convert JavaScript code to Google Appscript

Looking for guidance on incorporating Javascript code into my Google Appscript. Here is the code snippet: I have a separate Stylesheet.html file saved. Can someone advise me on how to invoke the functions within the html file? <script> //google. ...

The image source is unable to locate the image

Adding an image to my React component is proving to be problematic as the alternative text keeps being displayed instead. In the Navbar component, this is how I am trying to include the image: <img src="../assets/images/nav_logo.png" alt=&quo ...

HTML input field that shows a hint text when selected

Is there a way to create a text box that shows a hint when clicked on? For example, you can see this feature by clicking on the address text box in the following link: ...

Checking for the Existence of a Database Table in HTML5 Local Storage

Upon each visit to my page, I automatically generate a few local database tables if they do not already exist. Subsequently, I retrieve records from the Actual Database and insert them into these newly created local tables. I am wondering if there is a me ...

Guide to automatically inserting text into an html form and submitting it without manual intervention

Currently, I am in the process of a project where my main goal is to design an HTML form for submitting replies. One interesting feature I want to include is an option for users who are feeling lazy to simply click on "auto-generate comment", which will ...

Animating a div in jQuery by creating a duplicate

I've spent hours scouring Google and StackOverflow for a solution to this particular issue I'm facing, but haven't been able to find one. Here's the problem: I'm currently in the process of creating a shopping website. When a user ...

Problem with the fixed header on a container causing a horizontal scroll bar

This scenario presents a bit of a challenge! I could solve it by adjusting the container's height, but that would disrupt the fixed position of the sticky header. My goal is to have a scrollbar visible in both the X and Y directions on the .scrollabl ...

Expanding a wrapper to fit the entire width of its content

I am facing an issue where the background color of a wrapper does not adjust to the overflowing content within it. How can I make sure that the background stretches behind all the content, regardless of its size? <div style="background-color: black;m ...

Having trouble installing $ npm i mini-css-extract-plugin. Any ideas on what might be causing the issue?

There seems to be an error in my setup. I am using Visual Studio Code with gitBash. $ npm i mini-css-extract-plugin npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: <a href="/cdn-cgi/l/email-p ...

Navigating through nested arrays in Laravel Blade templates

I have an array that is displaying the code below after being dumped. array:1[ "123"=>array:3[ "test1" => 12345 "test2" => "test" "test3" => 123 ] ] When trying to display each element in an HTML table, the val ...

What is the process for loading a PHP page dynamically within the <DIV> of another PHP page?

At this moment, I have two PHP pages named test1.php and test2.php. In the test1.php page, there are 2 DIVs: one labeled "SubmitDiv" and the other "DisplayDiv". Inside the SubmitDiv resides a Submit button. The desired functionality is that when a user cli ...

Generate a dynamic image using CSS and either a div or a span tag

My image is intricately carved into several slices. You can view it here <!--Force IE6 into quirks mode with this comment tag--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.d ...

What is the process for inserting an SVG object into an HTML document?

Currently, I am experimenting with d3.js examples to create visual graphs. Here is the link for reference. Below is the snippet where I've implemented the LineChart function to construct the graph, with Django as the backend. {% load static %} < ...

Having trouble sending correct true/false values for selected radio buttons on an Angular5 table, often requiring users to click them twice to submit the appropriate values

My goal is to assign true or false values to selected radio buttons in each row and then form an object for submission. To distinguish between the radio button values in each row, I have used {{k}}+{{sizeobj.rbSelected}} as the value which is causing issue ...

I am looking to incorporate an OVG video onto my website

I have a video in OVG format that I want to add to my website. Since I am not very familiar with this file type, I'm concerned about how it will perform across different web browsers. I know that Firefox can play the file, but I'm unsure about In ...

Choose a specific cell in the table and store it in the session

I am new to working with PHP and have never dealt with sessions before. My current goal is to randomly select a table cell and save its location (x,y coordinates) in a new session. Below is the code I have so far, but I am unsure of what steps to take ne ...

What is the reason behind having a selectedOptions property rather than just a selectedOption?

Why does the selectedOptions property of select return an HTMLCollection instead of just one HTMLOptionElement? As far as I understand (correct me if I'm wrong), a select element can only have one selected option, so why do I always need to access it ...

Tips for utilizing Jinja2 to produce a custom HTML email design?

I am trying to dynamically display data in an HTML email template using Jinja2 and Python. I am fairly new to both languages, but here is what I have accomplished so far: Started with my boilerplate code dynamic /dynamic.html /script.py I have cr ...