What is the best way to manage the width and height of my HTML banner?

My goal is to set the width of my HTML banner to 915px. Despite having specified 915px in the .box-row, the banner's size ends up being 938px for some unknown reason.

Additionally, I'm curious about how I can manage the height of the HTML banner as well.

Jsfiddle: http://jsfiddle.net/tKn9f/5/

<div class="box-row">
<div class="box-form-body">
        <h3>
            See What You&#39;re Missing</h3>
</div>
<div class="box-form-button">
    <img alt="Learn More" height="100" src="http://www.robindelillo.fr/img/home/seeMoreButton.png" width="100" />
</div>

.box-row {
width:915px;
padding:10px;
border:1px solid #e2e3e4;
margin-top:50px;
overflow: hidden;
background-color:#f66511;

}

.box-row h3 {
    font-family:SegoeBold, Helvetica, Arial;
    font-size:1.3em;
    font-weight:normal;
    color:#fff;
    margin: 0;
}
.box-form-body {
    display: inline-block;
    vertical-align: middle;
    width: 75%;
    padding: 0 0 0 2em;
}
.box-form-button {
    display: inline-block;
    vertical-align: middle;
    width: 15%;
    padding: 0 0 0 2em;
}
.box-form-button img {
    vertical-align: bottom;
}

Answer №1

Revamp your next class assignment.

.container {
max-width:600px;
padding:20px;
border:1px solid #ccc;
margin-top:30px;
overflow: hidden;
background-color:#336699;
height:200px;
}

You may introduce a height attribute to determine the banner's desired height, subtracting the top and bottom padding values.

Answer №2

To achieve a total width of 895px, you must account for the additional 20px created by the 10px padding on each side. This means setting the actual width to be 915px.

.box-row {
    width: 915px;
    padding: 10px;
    border: 1px solid #e2e3e4;
    margin-top: 50px;
    overflow: hidden;
    background-color: #f66511;
}

Answer №3

When dealing with borders, widths, and padding in CSS, they are typically added to the width or height unless you alter the box-model settings. For more information, refer to this link: http://www.w3.org/TR/css3-ui/#box-sizing0

Answer №4

When inspecting the element, it is evident that the padding on the left and right has been set to 10 pixels each, with a border of 1 pixel on both sides, totaling 937 pixels.

To address this issue, you have two options:

.box-row {
width:915px;
/*  padding:10px;
    border:1px solid #e2e3e4;*/
margin-top:50px;
overflow: hidden;
background-color:#f66511;
}

Alternatively, you can adjust the width to total 915:

.box-row {
width:893px;
padding:10px;
border:1px solid #e2e3e4;
margin-top:50px;
overflow: hidden;
background-color:#f66511;
}

You can view a screenshot from Chrome DevTools here.

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

Resolved plugin issue through CSS adjustments

Take a look at this template 1) After referring to the above template, I developed a fixed plugin using JavaScript. 2) Clicking the icon will trigger the opening of a card. 3) Within the card, I designed a form using mdb bootstrap. Everything seems to ...

Creating an automatic image carousel using a combination of Jquery, Javascript, and CSS

I have been working on creating a slider using jQuery and javascript, but I am facing some issues with the autoplay functionality and the next-previous buttons. This slider is intended for displaying images as a title indicates. Can anyone assist me with i ...

Could leaving the src attribute empty trigger a request on all web browsers?

I'm curious about the safety of using an html image tag like this <img src width="30" height="20"/> When the ImageUrl is not set in ASP.NET, the Image control renders like this. I will populate the src attribute later on the client side I ju ...

Is it acceptable to assign unique names to individual arrays within a multidimensional array?

I was curious about the possibility of naming arrays within a multi-array, similar to how it can be done with individual arrays. For example: var cars = new Array(); cars[0] = "Saab"; cars[1] = "Volvo"; cars[2] = "BMW"; I was wondering if there was a way ...

AngularJS - Textarea not resetting content on ng-click event

Having an issue with my textarea. When attempting to clear it using ng-click, nothing happens... Can anyone provide assistance? Here is my code for testing: My app If you prefer to view it here: HTML : <div ng-controller="Ctrl1"> <d ...

What might be causing the jQuery UI Spinner arrow buttons to not appear?

Once I implemented a very basic version of the jQuery UI Spinner Widget, I encountered an issue where the up and down arrow buttons were not displaying. Clicking on the area where the buttons should be triggered the Spinner events and the number incremente ...

Utilize AngularJS $sanitize to convert characters into HTML code

When attempting to decode characters using $sanitize, I encountered a problem. I must use the $sanitize service instead of ng-bind-html, yet I am getting different results with each one. Despite ng-bind-html utilizing $sanitize internally, the outputs are ...

Swapping values between HTML tables and arrays with the power of JavaScript

I have a unique table structure that I need help with: https://i.sstatic.net/fr7oJ.png My current table has 2 rows and multiple columns, but I want to change it to have 2 columns and multiple rows like this: https://i.sstatic.net/uhkp9.png To create th ...

Retrieving the following element

I am trying to retrieve the next sibling element of one that contains the text "Yes". Unfortunately, I can only use the text "Yes" and part of the id attribute, as the number (e.g.. 106) is not available. Due to this limitation, I am unable to directly acc ...

Utilizing a JavaScript class method through the onchange attribute triggering

I am facing an issue with a simple class that I have created. I can instantiate it and call the init function without any problems, but I am unable to call another method from the onchange attribute. Below is the code for the class: var ScheduleViewer = ...

Role-based dynamic layout

I am currently working on a website that requires user login functionality. To achieve this, I am utilizing materialise-css and Angularjs for the front-end development, while the back-end is powered by Java-Hibernate (as Spring is not an option in my case) ...

Implementing a function as the `data-*` attribute for an element in Angular 6

I have a question about my component.ts file: import { Component, OnInit, AfterViewInit, ElementRef, Inject } from '@angular/core'; import { DOCUMENT } from '@angular/platform-browser'; import { environment } from '../../../enviro ...

Uploading pictures to a directory and storing their filenames in a database with the help of PHP

I'm facing a challenge trying to upload 2 files into a folder and save their names and image paths in a database. Below is my HTML code for reference: <input class="field2" type="file" name="file[]" multiple="multiple" /> Here is the PHP code ...

CSS table row border displaying irregularly in Chrome and Internet Explorer

I recently created a basic table with bottom row borders. Surprisingly, the borders display perfectly in Firefox but only partially in Chrome and IE 10: <div style="display:table; border-collapse: collapse; width: 100%"> <div style="display:table ...

Having trouble with Python Bottle <br /> not functioning properly?

I encountered a perplexing issue and I am unsure of how to resolve it: There is a text area where users can input their text. For example, let's say the following is entered : This is the user's text After storing this in my database and ret ...

Unresolved Issue: Jquery Modal Fails to Activate on Subsequent Click for Ajax-

When I make an Ajax call, I load HTML into a div. This HTML content contains a jQuery modal that opens when clicked. However, on the first click, the modal opens correctly. On subsequent clicks, I receive the following error in the console: Uncaught Type ...

Is the accept attribute of the input not recognizing application/json as a valid input type?

My application allows users to upload files, including JSON files. While most browsers recognize file extensions specified in the accept attribute of the input element, Safari may not always behave as expected. In cases where MIME types need to be used, sp ...

Overflow issues with flexbox design on mobile devices

Hello, I'm currently working on creating a sliding panel of images. While I have successfully implemented it, I am encountering some browser compatibility issues. The sliding panel functions perfectly on Chrome desktop, however, when viewed on mobil ...

A step-by-step guide to building a table with an array in Laravel

I am completely new to the world of programming. My current project involves creating an application using Laravel 5.1. I have a large amount of data stored as a multidimensional array and now I need to display this data in a table format. Here is a sample ...

Switch your attention to the following input text using AngularJS

In my controller, I have an object variable called `myObject` with 3 input text fields in the user interface. I am looking for a way to automatically shift the focus to the next input field once the current one reaches its maximum length. var myObject = ...