Is it possible for something to collapse horizontally at 100% width

Why are two DIV elements losing their 100% width in the CSS when the browser is resized?

Any suggestions on how to fix this issue would be greatly appreciated.

Thank you,

HTML

<div class="featured">    
    <h1>Name <span class="desc">This is a sample</span></h1>
</div>

<div class="aquabar">
    <div class="aquacont">
        Sample Description
        <h2>Some more information that is applicable</h2>
    </div>
</div>

CSS

.featured {
    width: 100%
    height: 400px;
    background-image: url("../img/featured-image.jpg");
    text-transform: uppercase;
    padding: 40 0 0 0;
}
.aquabar {
    width: 100%
    height: 100px;
    background-image: url("../img/featured-bg.jpg"); 
    background-color: #49aca9;
    margin: -30px 0 30px 0;
}

Answer №1

To ensure your 100% div includes padding and margin, simply add box-sizing:border-box to the CSS code.

 .highlighted {
width: 100%
height: 400px;
background-image: url("../img/featured-item.jpg");
text-transform: uppercase;
padding: 40 0 0 0;
box-sizing:border-box;
}
.stripe {
width: 100%
height: 100px;
background-image: url("../img/stripe-background.jpg"); 
background-color: #49aca9;
margin: -30px 0 30px 0;
box-sizing:border-box;
}

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

Is there a way to prevent on-click errors in ReactJS that someone can share with me?

The onclick listener was expected to be a function, but instead received a value of string type. getListener@http://localhost:3000/static/js/bundle.js:18256:15 accumulateSinglePhaseListeners@http://localhost:3000/static/js/bundle.js:22846:39 <button on ...

the process of triggering animation to start automatically when a button is clicked in Web Development

I'm looking to create a React component that triggers an animation when clicked. I have a few options in mind: If the props are changed in the middle of the animation, it should restart the animation. The props can be changed by clicking a button on ...

Adding CSS code to my index.css file in React is not reflected in my application

I've been following a tutorial on YouTube about reactJS, and the YouTuber recommended importing a CSS file into index.css to properly style the website. However, when I tried copying the CSS code and importing it into both App.js and Index.js, nothing ...

Python: HTML regex not finding a match

This is the code snippet I am struggling with: reg = re.search('<div class="col result_name">(.*)</div>', html) print 'Value is', reg.group() The variable 'html' holds content like this: <div class="c ...

Is there a way to distinguish between two URL requests originating from separate HTML pages but sharing the same namespace within views.py?

In order to familiarize myself with django, I am in the process of creating a basic e-commerce website similar to eBay. To allow users to remove an item from their watchlist, I have included two identical links in separate HTML files. These links enable us ...

Is it possible to rearrange div elements within different containers using media queries and CSS in Bootstrap4?

I've been utilizing the first/last utility in BS4, but my scenario requires relocating an element to and from a completely different section of the page. For instance, let's imagine I have the following setup: <div id='area1'> ...

By employing .replacewith to swap out images while preserving the IDs, the images lose their hover functionality

Whenever the user hovers over the image tagged with "id=dot0001", a table having id= "info0001" that includes a checkbox with id="checkbox0001" becomes visible. The user can then check the box, which replaces the image with id="dot0001" with another image ...

How to Filter, Sort, and Display Distinct Records in an HTML Table with jQuery, JavaScript, and

In the HTML page, there will be a total of 6 tabs labeled A, B, C, D, E, and F along with 2 dropdowns. The expected behavior is as follows: The user will choose a value from the 2 dropdown menus. Based on the selected value, filtering should be applied to ...

Implementing Multiple Shared Footers in Rails 3

Looking for a solution to display unique footers in Rails? For instance, displaying one footer on the homepage and another footer on the rest of the site. Has anyone successfully implemented this before? I was considering using an if statement based on th ...

Expanding the dropdown menu depending on the selection of the radio button

I am looking to implement a feature where the drop-down option is displayed or hidden based on the selection of a radio button in AngularJS. If the "Overall Company" radio button is selected, then the drop-down element should not be shown. If the "Demogra ...

What is the best way to integrate LESS css into a Reactjs application?

I am looking to incorporate LESS into my React app, but I have been unsuccessful in finding a solution through Google. As a newcomer to ReactJs, I lack deep knowledge and would greatly appreciate guidance on installing Less. If anyone is able to help me ...

What methods can be used to identify the specific Router component being rendered in React?

I am currently working with a Navbar component that I want to render with different CSS styles using styled-components based on the route of the component being rendered. How can I determine whether that component is being rendered or not? const NavbarCont ...

Trouble getting CSS to load in Webpack

I'm having some trouble setting up Webpack for the first time and I think I might be overlooking something. My goal is to use Webpack's ExtractTextPlugin to generate a CSS file in the "dist" folder, but it seems that Webpack isn't recognizi ...

Eliminate the Material Stepper heading

Is there a way to remove the header navigation from the material stepper? I've tried using the following CSS code without success: .mat-horizontal-stepper-header-container{display: none} You can view the stepper on Stackblitz by clicking this link: ...

Tips for aligning the contents of multiple tables in HTML to the center

Currently, I am in the process of designing a website where there will be four titles displayed above four images, with corresponding descriptions below each. I have utilized two separate tables for the titles and descriptions. While the layout appears fin ...

Issue with CSS: Hover effect causing unexpected additional white space

My main goal is to implement a hover effect that covers an entire section, but I'm facing some challenges. When I hover over my products, it doesn't behave as expected and adds extra white space below while not covering the section properly. Thi ...

What is the reason for being unable to remove the event listener from a sibling element?

function show1() { console.log("ok1"); document.getElementById("a2").removeEventListener("click", delegate); } function show2() { console.log("ok2"); } function show3() { console.log("ok3"); } function delegate(event) { var flag = event.target ...

Persistent hover state remains on buttons following a click event

In my current project, I am dealing with a form that has two distinct states: editing and visible. When the user clicks on an icon to edit the form, two buttons appear at the bottom - one for saving changes and one for canceling. Upon clicking either of th ...

Using an if else statement in JavaScript to show varying content depending on the browser

My code includes a feature to detect the user's browser and display different content within <div> tags based on that information. However, my JavaScript logic seems to be malfunctioning. The web application is constructed using asp.net and vb. ...

Two divs positioned on the left side and one div positioned on the right side

Hey there, I am attempting to align 2 divs on the left side with one div on the right. #div1 #div2 #div1 #div2 #div3 #div2 #div3 #div3 The challenge is to have #div2 positioned between #div1 and #div3 when the browser window is resized smaller. Currentl ...