What is the best way to create padding for divs in 960gs without relying on an inner div?

I'm currently working with 960gs and facing the challenge of adding padding to div elements without resorting to using an additional inner div.

When I attempt to add padding directly to the main div, it disrupts the layout established by 960gs. The only solution I've come up with involves nesting another div inside and applying the padding to that nested element.

While this workaround does resolve the issue, I personally find it redundant to have a second div solely for padding purposes. Are there any alternative approaches that can be explored?

Answer №1

Is box-sizing functioning as expected?

https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

div {
    width: 100px;
    box-sizing: border-box;
}

border-box The width and height properties now include padding and border, but not margin. This is the box model utilized by Internet Explorer when in Quirks mode.

Answer №2

One common issue with grid systems is the padding problem, which unfortunately doesn't have a straightforward solution. The best workaround is to add extra markup, such as an inner div without a "grid_xx" class.

If you're up for some extensive coding, you can also apply padding directly to the child elements. Here are the two approaches:

<div class="grid_12">
 <div class="inner_div" style="padding:10px">
  <p>This is some sample text</p>
 </div>
</div>

Alternatively, you can skip the inner div and style the child elements like this:

<div class="grid_12">
 <p style="padding:10px">This is some sample text</p>
</div>

You could use CSS instead of inline styles, but the concept remains the same :)

I hope this information proves helpful.

You might also want to explore the Blueprint or YUI CSS frameworks, although they may encounter similar padding issues.

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

Turning a multi-row table header into div elements using Javascript

Does anyone have a JavaScript algorithm that can analyze a table header and then output the equivalent DIV elements as either a string or object of DOM? The table header has the following structure: Here is an example of the HTML: <thead> <t ...

Selective Circle Appending Techniques

I am having some issues with my bubble chart code. The data file I am working with contains instances where the GDPperCapita and/or LifeExpectancy values are either 0 or NaN, causing problems when appending circles to the chart. I would like to know if th ...

What are some tips for designing HTML email templates?

Check out this example of an HTML email <div style="width:650px;"> <div class="begining"> <p> Dear <span>' . $name . '</span><br/>Thank you for your booking </p> & ...

Bootstrap 4 Dropdown Menu not displaying on website

Hello everyone, I'm encountering an issue with Bootstrap v4-alpha6 where my dropdown-menu is not appearing as expected. I tried using a sample code from the Bootstrap documentation and it worked fine, but for some reason, my implementation does not e ...

What is the Best Way to Send Multiple Values using a Single Submit Button?

Hello, I am working on a website where users can send emails to each other. However, I am facing an issue with the submission process - it is not submitting both values at the same time. My form consists of a text box for the email address and a text ...

Guide to creating uniform width for asp:buttons using bootstrap and css

I am currently working on developing an asp website using bootstrap. One query that I have is regarding how to ensure all the asp buttons have the same width without having to add spaces for padding. I attempted creating an alternative CSS file and applied ...

a:hover CSS style altering the behavior of buttons with images in a web browser

Earlier I attempted to ask this question from my phone, but it ended up being overly convoluted and confusing. Therefore, I have decided to start fresh after locating a working PC. Unfortunately, due to the sensitive nature of the project, I am unable to p ...

The input field or help text fails to change to a red color when the field contains invalid information

Previously, I developed an Angular 2/4 application using Bootstrap 3 and Reactive Forms for field validation. In this setup, when there was an error in input fields, the border of the field turned red and an error message would display below the field in r ...

CSS briefly displays overridden styles before applying the final styling

Presently, I have implemented a third-party library directive for a UI toggle button. I made some adjustments to the background color and positioning of the toggle button to align with my business requirements. Instead of the default light green for true a ...

Generating dynamic HTML content in React using a variable within a string

Currently, I am utilizing TypeScript in a React application. I am receiving the following data from an API: a) a list of variable names ["name", "surname"] b) several strings in simple HTML form with variables "<p>Hello, ho ...

What is the best way to declare variables in an HTML document that can be accessed by an external JavaScript file when including the JavaScript code in the HTML?

Issue at Hand: In my attempt to streamline the process, I have encountered a problem. Everything works perfectly when I embed the JavaScript code in each HTML file and manually input all the variables. However, when I attempt to bundle it up as follows, it ...

Ways to automatically display the Nebular Accordion using NgFor

Struggling with the latest Nebular version in Angular 7, I'm encountering a problem when using the nebular accordion component. Problem: The default behavior should have only one accordion expanded at a time, but setting expanded = true expands all of ...

JavaScript - Shuffle Cards Memory Game Function

I've been working on developing a memory game using JavaScript, and I've encountered some challenges along the way. After successfully designing the HTML and CSS components, my focus has now shifted to implementing the JavaScript functionality. O ...

Guide to reordering elements (radio buttons) retrieved by jQuery selector

I am working with a table containing radio buttons. Through a jQuery collection, like c = $('input[name=mybuttons]'), the elements are accessed by rows, so that c[0] corresponds to the top left cell. Is there a way to change this order? For exa ...

AngularJS allows us to easily include the route provider templateUrl path in the view div, making

I have the following route provider setup: $routeProvider .when('/', { templateUrl: '/slapppoc/Style Library/TAC/Views/tarification/home.html', controller: 'homeController' /* resolve: { // This f ...

How to line up scrollable tables columns with the header using CSS

Link to JsFiddle : http://jsfiddle.net/gfy4pwrr/1 <table cellspacing="0" cellpadding="0" border="0" width="325" > <tr> <td> <table cellspacing="0" cellpadding="1" border="1" width="300" > <tr> ...

Facing a selection list issue on a web application built with Flask and Vue.js

I'm trying to integrate Flask and Vue.js together, but I've encountered an issue with my select element. The following code snippet is present in my HTML file: <div class="col-sm-10"> <select class="form-select" v-mod ...

Is there a solution or workaround for the issue of fake anti-aliasing in Microsoft Edge when it comes to the border of sticky headers using Bootstrap 4?

In my current project, I came across a Pen shared by Balaji731 on Bootstrap 4 table with the scrollable body and header fixed. While testing the Pen in Microsoft Edge, I noticed that when <th> borders are enabled, they disappear while scrolling, cre ...

Is it possible to modify the menu design for a specific page?

Is there a way to customize the appearance of a menu on a specific page of your website? My website's "Main Menu" has 6 menu items, and I'm currently using a menu module called "AS Superfish Menu". This module is set up to make the menu responsi ...

Exploring Javascript parameters with the power of jquery

Is it possible to pass a parameter from PHP into a JavaScript function within HTML? I am currently facing an issue where my code crashes when it reaches a certain condition. This is the code snippet causing the problem: $str="<input type='submit&a ...