Change the maximum width set by the parent class

Currently, I am implementing a responsive grid layout that accommodates both mobile and desktop screen sizes. My objective is to split the footer into two rows and insert a line between them that spans the entire width of the screen. However, a challenge arises due to the presence of a container class with max-width: 1700px for desktop sizes. To address this issue, I have introduced a new class called intermediate-line with max-width: none (including initial) in an attempt to override the container's max-width property. Below is the snippet of my code:

/********CSS*******/
.container{
   padding-right: 15px;
   padding-left: 15px;
   margin-right: auto;
   margin-left: auto;
   max-width: 1170px;
}

@media(min-width: 48em){
   .container > .intermediate-line{
       max-width:none;
       border-top: solid 1px;  
   }
}
/******************/

/*******HTML*******/
<footer class="background-primary">
<div class="container">
  <div class="row">
    <div class="col-1-4">logo</div>
    <div class="col-1-4">address</div>
    <div class="col-1-4">Phone Number</div>
    <div class="col-1-4">Social Media</div>
  </div>

  <div class="intermediate-line"></div> 

  <div class="row">
    <div class="col-1-4">copyright</div>
    <div>Privacy Policy</div>
    <div>Terms of Use</div>
  </div>
</div>

Answer №1

To ensure the content stretches to fit the entire screen regardless of container width, simply create two containers with a max-width property set to 100%.

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
  max-width: 1170px;
}
.intermediate-line {
  max-width: 100%;
  border-top: 1px solid;
 }
.containerx {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
  max-width: 70px;
}
.intermediate-linex {
  max-width: auto;
  border-top: 1px solid;
 }
.containery {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
  max-width: 1170px;
}
.background-primaryy
{max-width: 180px;}
.intermediate-liney {
  max-width: initial;
  border-top: 1px solid;
 }
<footer class="background-primary">
  <div class="container">
    <div class="row">
      <div class="col-1-4">logo</div>
      <div class="col-1-4">address</div>
      <div class="col-1-4">Phone Number</div>
      <div class="col-1-4">Social Media</div>
    </div>
  </div>
  <div class="intermediate-line"></div>
  <div class="container">
    <div class="row">
      <div class="col-1-4">copyright</div>
      <div>Privacy Policy</div>
      <div>Terms of Use</div>
    </div>
  </div>
  </footer>

<br><br>
<footer class="background-primaryx">
  <div class="containerx">
    <div class="row">
      <div class="col-1-4">logo</div>
      <div class="col-1-4">address</div>
      <div class="col-1-4">Phone Number</div>
      <div class="col-1-4">Social Media</div>
    </div>
 
  <div class="intermediate-linex"></div>
 
    <div class="row">
      <div class="col-1-4">copyright</div>
      <div>Privacy Policy</div>
      <div>Terms of Use</div>
    </div>
  </div>
  </footer>
<br><br>
<footer class="background-primaryy">
  <div class="containery">
    <div class="row">
      <div class="col-1-4">logo</div>
      <div class="col-1-4">address</div>
      <div class="col-1-4">Phone Number</div>
      <div class="col-1-4">Social Media</div>
    </div>
 
  <div class="intermediate-liney"></div>
 
    <div class="row">
      <div class="col-1-4">copyright</div>
      <div>Privacy Policy</div>
      <div>Terms of Use</div>
    </div>
  </div>
  </footer>

Answer №2

From what I know, the structure of Bootstrap typically follows:

  1. container
  2. row
  3. col-[size]-[n1 + n2 + n... = 12]

To see how it works, switch to Full Page mode and resize the page.

SNIPPET

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1, user-scalable=no">
  <title>00A00</title>
  <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
  <style>
    /********CSS*******/
    .container {
      padding-right: 15px;
      padding-left: 15px;
      margin-right: auto;
      margin-left: auto;
      max-width: 1170px;
    }
    footer {
      border: 1px solid black;
      border-bottom: 0 none transparent;
    }
    
    @media(min-width: 48em) {
      /*768px*/
      footer.row .left-division {
        border-right: 1px solid black;
      }
      footer.row {
        border-top: 1px solid black;
      }
    }
    /******************/
  </style>
</head>

<body>
  <div class="container">
    <!--*******HtML*******-->

    <footer class="row">
      <div class="col-md-6 left-division">
        <div class='row'>
          <div class='logo col-sm-6'>
            <img src='http://placehold.it/50x50/000/fff?text=LOGO'>
          </div>
          <address class='col-sm-6'>
            <div>Address</div>
            <div>Phone Number</div>
            </address>
        </div>
      </div>

      <div class="col-md-6">
        <div class='row'>
          <div class='col-sm-6'>
            <div>Social Media</div>
          </div>
          <div class='col-sm-6'>
            <div>copyright</div>
            <div>Privacy Policy</div>
            <div>Terms of Use</div>
          </div>
        </div>
      </div>
    </footer>
  </div>
  
  <script>
  </script>
</body>

</html>

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

CSS Alignment in React with Material UI

Is there a way to align one button to the left while centering the other two? To see an example in Codesandbox, please visit HERE <DialogActions sx={{ justifyContent: "center" }}> <Button>Left</Button> <Button on ...

What is the best way to adjust the height and width of a Modal in a react-bootstrap

I'm currently working on implementing a React Bootstrap Modal in my project. However, I am facing an issue where the dialog appears to be too small for my requirements. I would like to make it bigger, but despite completing the code, it seems that the ...

Disconnecting socket when A-tag with Href is clicked

Currently, I am working on a project that involves using socket.io. In this project, I need to provide users with links to download files. <a href="<path>" >Link Name</a> Interestingly, whenever I click on the link to download the file, ...

Challenges related to maintaining a webpage's content using AJAX

I have a form that I want to use to send and insert the values into my database. After the values are inserted, I would like to clear the input fields of the form and display a success message. Here's an example of how I would like it to look: Clear ...

Using several scripts on a single HTML page to create a rotating banner

Seeking to implement an automatic rotating banner for content in a footer section. Encountering an issue where the first two slides stop after changing once, and the third slide updates faster than expected. Each of the elements has unique class names, but ...

Node-modules CSS

In my React application, I am utilizing CSS modules. By configuring modules:true in my webpack.config.js, I can successfully apply styles from files within my src folder. However, when importing components from node-modules, the corresponding CSS is not be ...

Contrasting Viewport on Android in Landscape and Portrait Modes

I've been working on a mobile site and in order to test it, I've set up different emulators for Android and used an iPhone emulator as well. The issue I am facing is that when I call window.innerWidth upon orientation change on the iPhone, the vi ...

Selenium and BeautifulSoup have the ability to manipulate numerical values within HTML elements

My goal is to retrieve the total number of yellow cards each team has received from this website: Take a look at my code below: driver = webdriver.Chrome(service=chrome_driver_path) driver.get("https://www.premierleague.com/stats/top/clubs/total_yel_ ...

Scroll dynamically to a div upon clicking and looping through its content

When the user clicks on the first paragraph with the class "targetgo", I want the page to scroll to the element with the class "size1". The same goes for the second paragraph with the class "size2" and so on. As I will have more than 25 similar instances ...

A guide on using wrapAll within an each loop in jQuery

I have a series of div elements in my HTML code: <div class="mainClass class_1"></div> <div class="mainClass class_1"></div> <div class="mainClass class_2"></div> <div class="mainClass class_2"></div> <di ...

Creating a Navigation Bar in Outlook Style Using Javascript and CSS

Looking for a navigation sidebar design similar to Outlook for my web application. I have seen options available as Winform controls and through Visual WebGUI, but these are Microsoft-dependent solutions. We need a Javascript & CSS based solution that is s ...

Do elements containing {visibility:hidden} properties exist within the HTML DOM structure?

Do HTML elements that have the css property visibility:hidden still exist within the DOM tree? ...

Is there a way to use jQuery to toggle a child element when the parent is clicked?

There are three images displayed on a webpage, each accompanied by a list of three events. The desired functionality is that when a user clicks on an event, the corresponding information should be displayed below that event. Below is the HTML structure: & ...

Side navigation bar functionality only kicks in after a page reload [Angular 4]

I currently have a functional Angular 4 application that includes a login feature. After logging in successfully, the page redirects to My HeaderComponent, which contains an image that toggles the sidebar when clicked. However, I am encountering an issue w ...

Create a regular expression to identify and substitute incorrect HTML properties

It's a harsh reality that my regex skills are lacking. Upon revisiting an old project, I stumbled upon some code that definitely needs attention. Take a look: strDocument = strDocument.Replace("font size=""1""", "font size=0.2") strDocument = strDocu ...

Styling background images in Angular 4 with ngFor loop

I am having trouble with using background image URLs. I have an array of image URLs, how can I incorporate them into the background image URL? <div class="col-lg-3 col-md-3 col-sm-6" *ngFor="let course of courses"><a> </a><div c ...

Can Bootstrap 4 CSS be used to display a yellow triangle with text in the bottom right corner of a card?

I'm having difficulty modifying the CSS to display a yellow triangle containing text in the bottom right corner of a Bootstrap 4 card. Is there a way to achieve this effect using CSS? This is how the current CSS output looks in a Bootstrap 4 card: h ...

When attempting to view the HTML source of a ReactJS page by clicking on "View Page Source," the

I am new to ReactJS and I'm looking to create a ReactJS website and then optimize it for SEO. However, when I try to view the page source, it only displays the content of index.html. I tried using server-side rendering as per the instructions provide ...

Utilize the DataTables plugin to arrange a column based on icons with hidden boolean values in rows

I am currently utilizing the DataTables plugin to enhance my HTML table. While I have managed to successfully implement most functionalities, I am facing a challenge with the boolean column. This particular column consists of icons representing X (value 0) ...

Struggling to align the header of a column to the center in a mat-table that is sortable?

I am working with a mat-table that has a sortable column similar to the example shown here, but I am having trouble centering the column headers using my CSS file. Interestingly enough, I am able to achieve this when making changes in the browser debugger! ...