Element imitating the edge of the screen extending to the edge of the container

Looking to customize a website design (utilizing bootstrap 4) with a gradient line that starts from the title and stretches all the way to the left edge of the container. While I have managed to set this up, the full gradient effect is not visible. To address this issue, I introduced a wrapping div.overflow-hidden that covers the entire width of the page and includes overflow-x: hidden;. The gradient line is implemented as an ::after pseudo-element attached to the h1 element.
Is there a pure HTML/CSS solution that ensures the complete gradient display at all times? The heading’s position on the page can vary, and due to its placement within a container, fixing a specific width for the pseudo-element isn’t feasible as it hinges on screen resolution. Refer to the code snippet below for my attempted solution:
Desired Outcome:
https://i.sstatic.net/DBuqD.png

.overflow-hidden {
  overflow-x: hidden!important;
  width: 100%;
}

.title-detail {
  position: relative;
  display: inline-block;
}

.title-detail::after {
  content: '';
  position: absolute;
  display: block;
  width: 100vw;
  height: 0.25rem;
  right: calc(100% + 2.25rem);
  background-image: linear-gradient(to right, rgb(72, 184, 171) 0%, rgb(97, 157, 191) 100%);
  top: 50%;
  transform: translateY(-50%);
}

.column-count-2 {
  column-count: 2;
  column-gap: 2rem;
  column-rule: none;
}
<div class="overflow-hidden">
  <div class="container">
    <div class="row justify-content-center">
      <div class="col-12 col-md-10 col-xl-8">
        <h1 class="title-detail">title of page</h1>
        <div class="column-count-2">
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin risus metus, lacinia sed erat vitae, dictum ullamcorper urna.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin risus metus, lacinia sed erat vitae, dictum ullamcorper urna.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin risus metus, lacinia sed erat vitae, dictum ullamcorper urna.</p>
        </div>
      </div>
    </div>
  </div>
</div>

Fiddle Link

Answer №1

Revised Answer

Here is a potential solution for you:

I made a small adjustment to

.title-detail::after {width: calc(((100vw - 1170px)/2) - 10px);}
and it resolved the issue for me. To demonstrate, I eliminated the .overflow-hidden.

Explanation -

.title-detail::after {width: calc(((100vw - 1170px)/2) -
  10px);}
means .title-detail::after {width: calc(((Screen Width - .container width[adjust via mediaquery with bootstrap] )/margins of both sides) - slight gap adjustment);}

/*.overflow-hidden {
  overflow-x: hidden!important;
  width: 100%;
}*/

.title-detail {
  position: relative;
  display: inline-block;
}

.title-detail::after {
  content: '';
  position: absolute;
  display: block;
  width: calc(((100vw - 1170px)/2) - 10px);
  height: 0.25rem;
  right: calc(100% + 2.25rem);
  background-image: linear-gradient(to right, rgb(72, 184, 171) 0%, rgb(97, 157, 191) 100%);
  top: 50%;
  transform: translateY(-50%);
}

.column-count-2 {
  column-count: 2;
  column-gap: 2rem;
  column-rule: none;
}

@media (min-width: 992px) {
  .title-detail::after {
    width: calc(((100vw - 970px)/2) - 10px);
  }
}

@media (min-width: 768px) {
  .title-detail::after {
    width: calc(((100vw - 750px)/2) - 10px);
  }
}
<!-- Bootstrap core CSS -->
<link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" media="screen">

<div class="overflow-hidden">
  <div class="container">
    <div class="row justify-content-center">
      <div class="col-12 col-md-10 col-xl-8">
        <h1 class="title-detail">title of page</h1>
        <div class="column-count-2">
          <p class="lead">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin risus metus, lacinia sed erat vitae, dictum ullamcorper urna.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin risus metus, lacinia sed erat vitae, dictum ullamcorper urna.</p>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin risus metus, lacinia sed erat vitae, dictum ullamcorper urna.</p>
        </div>
      </div>
    </div>
  </div>
</div>

Hopefully this resolves your issue. This has been tested on Firefox, Chrome, and Safari.

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

The cancel button for the input type "search" does not appear on Firefox, Internet Explorer, and Edge browsers

.hs-search-field__input { color: #111d33; border-bottom: 3px solid #111d33; appearance: searchfield; -moz-appearance: searchfield; -webkit-appearance: searchfield; -ms-appearance: searchfield; color: #fff; border-radius: 0px ...

Display the output of a MySQL query in a PHP array

Imagine I have the MySQL table results shown below: ID price ------------- 1 10 2 20 3 30 My goal is to take these values and store them in a PHP array, then display them as an HTML table row by row. One way to achie ...

Creating layered images with CSS Grid

Visit this link for more details I've been attempting to create an overlap effect with 3 photos using CSS Grid. My desired outcome looks like this: Click here to see the desired result I followed tutorials that demonstrate the same method, but unfo ...

Ways to create an inline effect for h3 and <hr> elements, or strategies for incorporating a horizontal line following a header

Is there a way to make the H3 and HR elements appear inline? In my design, I want a horizontal line to come immediately after the title without breaking onto the next line like it currently does. <div class="row"> <h3 class="col-md-4 col-sm ...

Switch the currently active tab in an Angular component using Bootstrap

I've been struggling with what seems like a simple issue for some time now. Despite searching through various Stack Overflow solutions, I can't seem to find one that fits my specific use case... The problem I'm facing involves an angular co ...

Can anyone suggest a more efficient approach to handling variations using CSS?

Within the message component, there are currently only two variants available: error and success. This project is built using vue3 script setup and utilizes SCSS for styling. <script setup lang="ts"> defineOptions({ name: 'Notificat ...

Printing Apex Oracle reports using Internet Explorer

I am facing a challenge with printing my page that contains two interactive reports. To enable printing, I have utilized a JavaScript function that triggers window.print(). I have incorporated CSS to adjust the layout of my tables when printed. @media pr ...

Using AJAX/JQuery along with PHP to instantly send notifications without refreshing the page for a contact form

Website URL: This website was created by following two separate tutorials, one for PHP and the other for AJAX. The main objective was to develop a contact form that validates input fields for errors. If no errors are found, a success message is displayed ...

I'm looking to add CSS transitions, like fade-ins, to a list of items in React in a way that the animations occur one after the other upon rendering. How can this be achieved?

I've scoured the depths of Stack Overflow and combed through countless pages on the internet in search of an answer to my query, but alas, I have not found a solution. So, my apologies if this question is a duplicate. Here's my conundrum: https ...

Troubleshooting issues with Bootstrap Accordion functionality within a React environment

After copying and pasting the Accordion code directly from Bootstrap, I'm facing an issue where the style is not consistent and the functionality isn't working as expected. Snippet from About.js: import React, { useState } from 'react' ...

Why isn't the ajax table showing up in my HTML?

I am facing an issue while trying to run an application that involves AngularJS, Ajax, and a Java Controller returning JSON. Despite my efforts, the table is not displaying in the HTML. I am new to working with Ajax and AngularJS, and need assistance troub ...

The button mysteriously vanishes on Github Pages, yet remains visible when viewing the

I recently completed a project on Github and created a corresponding Github Page for it. The page features multiple buttons with different functions, but oddly enough, one specific button is not showing up on the Github Page. Surprisingly, it appears perfe ...

Show a collection of files in a table format

Here is the current code I have: index.html <!DOCTYPE html> <html> ... </form> </div> </body> </html> And here is my code.gs function doGet() { return HtmlService.createHtmlOutputFromFile('index'); } ...

Is there an issue with my straightforward AJAX demonstration? Must your website be hosted on a server for it to work properly?

I'm having trouble understanding what's causing the issue as all my files are located in the same directory. I'll begin by sharing the HTML code, followed by the AJAX script, and lastly, the .txt file contents. HTML: <!doctype html> ...

Creating a dynamic NxNxN matrix from a basic array in Vue.js

Consider an array: listItems = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ,13 ,14 ,15 ,16, 17, 18, 19, 20, 21, 22, 23]; I would like to transform it into a 3-dimensional Array((Matrix of ROW x COLUMN)x SET according to the number of instances. Here is an exa ...

Tips for creating multiple full-screen overlays in HTML

I am new to the world of web development and I am currently working on implementing a set of buttons that will trigger specific overlays when clicked. I found the following code snippet on W3schools which creates a button along with an overlay effect. < ...

Adjust the dimensions of a specific image in a lineup

I'm currently in the process of developing a website and I've encountered an issue with lists. Specifically, I'm trying to make one particular image within the list slightly larger as it appears smaller compared to the others. For visual re ...

What is the best way to dynamically create list items for an unordered list using ASP.NET?

In my development project, I am facing an issue where an error panel needs to be displayed on a page in case of errors. Currently, the error messages are being appended to a string and then added to a label. However, dealing with multiple errors makes this ...

Maintaining the proportions of images in different screen sizes when resizing

I apologize if this question has already been addressed, but I have been unable to find a solution that works for my specific issue. My Gallery consists of a side list of available images in one section, which when clicked changes the image source in anot ...

Linking to a specific div within a Vue.js component

Currently working on a Vue.js project, I am encountering an issue with linking an anchor to a specific div within a component. The anchor in question is as follows: <a href="#porto" class="porto-button">Porto, Portugal</a> Accompanied by the ...