Using a 100% width setting will only occupy half of the screen on mobile devices or laptops

It should actually be slightly less than 100% because setting it at 100% causes the content to be off screen to the right. When I view my page on a tablet or laptop, it zooms into the top left corner of the screen. If I zoom out, I notice that the divs only occupy about half of the page horizontally. I've experimented with min-width but haven't had any success.

.first {
                height: 75px;
                width: 99.55%;
                background-color: red;
                margin-top: 19px;
                border: 3px yellow solid;
                min-width: 1000px;

                margin: 0 auto;

 }

 h2 {
                text-align: center;
                width: 100%;
 }
 <div class="animated fadeInUpBig first o">
        <h2>Adjust positioning for mobile devices</h2>
 </div>
 <div class="animated fadeInUpBig first t">
        <h2>More updates coming tomorrow evening</h2>
 </div>
 <div class="animated fadeInUpBig first tr">
        <h2>Targeting halfway progress by weekend</h2>
 </div>

Answer №1

If you wish for each red block with a yellow border to have a specific width (such as 90%, 300px, etc.), you can apply box-sizing: border-box to the element. This will allow the width to factor in both padding and border. Keep in mind that since both the .first (a div) and the h2 are block-level elements, they will automatically take up 100% of their parent's width.

I adjusted the margin-top property by combining it with margin: 0 auto;, ensuring that the margin doesn't override the top margin.

In terms of the border shorthand, it should include width, style, and color. I made a slight modification to reflect this format.

Lastly, most browsers have a default margin of 8px for the body element. To make your boxes touch the edges of the browser window, you'll need to add that final body property or utilize a common CSS reset (such as ).

.first {
  height: 75px;
  background-color: red;
  border: 3px solid yellow;
  min-width: 1000px;
  margin: 19px auto 0;
}

h2 {
  text-align: center;
}

body {
  margin: 0;
}

http://codepen.io/phawley/pen/amLRYK

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

error with security token across various design templates

I am facing an issue with my template (index.html, which extends base.html) that contains a form with a csrf_token and works perfectly. I am using JS/Ajax to send data to my view without any problems. However, when I copy/paste the same form into another ...

Executing transitionend Using Jest for Unit Testing

I am currently utilizing angular 8 along with Jest for unit testing. My challenge lies in adding a listener for the 'transitionend' event on an element, and I'm struggling to find a way to simulate/mock this event using Jest. this.animatedEl ...

Is there a way to adjust the "click priority" for buttons that overlap?

I am facing an issue with a project where I have two buttons overlapping: a red button at the bottom and a yellow button on top. The problem lies in the fact that the yellow button is covering part of the red button. I want the red button to remain visibl ...

Having trouble with the contact form sending emails

My contact form box seems to be having trouble directing the mail to my email. When I hit the send message button, it just refreshes the page in a continuous loop. <div class="wow fadeInUp col-md-6 col-sm-12" data-wow-delay="1.6s"> <h1>I ...

"Get rid of the arrow in Bootstrap's dropdown menu

I'm currently using a bootstrap template that features an accordion menu. However, I have come across a scenario on one section of the page where I do not require the items to expand and show additional text, therefore, I would like to remove the arro ...

Tips for stopping table column width growth when an icon is inserted into a cell dynamically

In the table I have, the header is clickable and when clicked, it triggers sorting. Clicking on the header title adds an icon (ascending or descending) to the right of the title, causing the column width to increase based on the size of the icon. Refer to ...

Can you explain the purpose of the property named "-webkit-min-logical-width"?

Recently, I encountered a CSS issue where setting the min-width property worked in Firefox but broke in Webkit. After experimenting with the Chrome inspector, I found that using the property -webkit-min-logical-width with a different value than min-width r ...

How can I identify when a browser window is maximized using JavaScript or CSS?

I am currently working on a dashboard designed for static display on large monitors or TVs for clients. My main goal is to implement CSS styling, specifically a snap-scroll feature, but only when the display is in 'fullscreen' or 'maximized& ...

Reverse the CSS animation direction

I am facing an issue with an animation that moves in one direction. I am looking to reverse the animation so it goes back to its original position: $('#right').click(function() { $('.container').removeClass('.move-left'). ...

disable readonly attribute on several fields by clicking button with jquery

I am struggling with selecting all the input fields of a row in my student details table at once when clicking the edit button. The fields are readonly and can be edited by clicking the edit button. Below is the HTML code snippet: <table class="table ...

Avoid text being abruptly cut off by the overflow:hidden property when utilizing flexbox column layout

I am looking to design a fixed height card that includes a title, body, and footer. The title and footer may consist of multiple lines, while the body text should expand to fit the remaining space. .card { display: flex; flex-direction: column; he ...

Adjusting the width of an element by modifying its border-collapse property

Is there a way to implement "border-collapse: collapse" without affecting the width of the element? The Issue: Without using the border-collapse property, the right and left borders appear bold because they are adjacent. Using the border-collapse propert ...

having numerous collapsible elements that trigger a single django view function, each one submitting a distinct value

I have multiple collapsible items that need to trigger the same Django function when submitted with different values. https://i.sstatic.net/1BO19.png Is there a way to achieve this without using a dropdown menu in Django forms? What modifications should ...

Guide on creating a darkening effect for lights

Seeking assistance on how to create a light-off effect when clicking on any of my textboxes. I discovered this concept on the following website: What I aim to achieve is that upon clicking a specific textbox, it will be highlighted. Upon clicking the sam ...

Tips on ensuring that a span element is positioned at the bottom of a table cell

Is there a way to position the span element at the bottom of a table cell in HTML: Here is the code snippet I'm working with: <td> <span class='cat-otsikko'>Product title</span> <span class='cat-hinta&apos ...

Javascript: Altering Link Color

After creating my own webpage with a unique light switch that inverts colors, I encountered an issue with changing the color of my links. Despite setting the anchor tags to transition to a different color, it just wouldn't work. Here is the HTML code ...

Active Bootstrap tab-pane when clicked

index.html <div class="ban_km font_bold"> <a class="redrct_tab" href="Maintenance-schedule">find out more</a> </div> maintenance schedule.html <ul id="leadbann" class="nav nav-tabs" role="tablist"> <li role="presentat ...

php - Can you identify the issue?

File Name: sms1.php Located at: Here is the PHP code for sms1.php: <?php //Variables to POST $user = "hidden"; $password = "hidden"; $mobiles = "$_POST[phone]"; $message = "$_POST[msg]"; $sender = "$_POST[sender]"; //Setting up CURL to send data via ...

Prevent body from scrolling when mouse is over a div, while keeping the position unchanged

Although I've come across a few discussions about this topic before (including one of my own), I'm still searching for an improvement on the only solution that has actually worked for me. My goal is to enable mouse wheel scrolling for a height-l ...

Resolving the Problem of Overlapping with Kendo UI Tabstrip and jQuery Tooltipster

Utilizing MVC4 and Kendo tabstrip along with jQuery Tooltipster to display validation messages. Encountering an issue where the validation message from Tab 1 overlaps on Tab 2 due to z-index. Attempts to set z-index for tooltipster-base have been unsucces ...