Tips for effectively using the Susy +pad mixin

How can I use the +pad method to add padding on a p element without extending it past a certain point? I've tried using +pad, but the p always goes beyond the desired stopping place. Take a look at this screenshot for reference:

The issue arises when the p with a yellow background extends beyond the middle of the 9th column, where the images stop. I want the p to stop there as well, and not extend further. The same problem occurs when using +prefix.

Below is the Susy code I am currently working with:


@import compass;
@import compass/css3;
@import compass/layout;
@import compass/utilities/lists/bullets;
@import susy;
@import normalize;
@import base;
@import media; 

/* Susy Settings */

$total-columns  : 4;
$column-width   : 60px;
$gutter-width   : 20px;
$grid-padding   : $gutter-width;

$container-style: fluid;

$tablet : 9;
$desktop : 14;

// Override Susy-grid-background to draw out horizontal lines
= susy-grid-background       
  +grid-background($total-columns, $column-width, $gutter-width, $base-line-height, $gutter-width, $force-fluid: true);

/* -------------------DESKTOP ----------------------------------*/
+at-breakpoint($desktop)
#page
    +container
    +susy-grid-background;

header
    +container
    +pull(.3);
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 0;
    padding-top: 0;
    z-index: 3;

    h1.logo
      +span-columns(2);
      font-size: 12px;
      // background: green;
      +hide-text;
      margin-top: 0;

      a
        svg
          +leader(1);
          float: right;
          width: 97px;
          height: 38px;

    .pagenav
      +span-columns(2);
      +leader(.5);
      clear: both;

      li
        margin-bottom: 1em;
        float: right;
        clear: both;
        a
          padding: 5px;


.main
    +span-columns(12 omega);
    z-index: 1;
    position: relative;

    .image-group-title
      +span-columns(10, 14);
      padding: 1em;
      +pad(1, 0, 10);
      +trailer(.5);

    img 
      +span-columns(10, 14);

    .img-4-wide
      +span-columns(5, 14);


.tile
    +isolate-grid(4, 12);
    +fluid-ratio(1/1, columns(4,12));


#footer
    margin: 0 1em;
    height: 80px;

Answer №1

Here are a couple of key points to consider:

  1. If you don't use the border-box box-sizing model, padding will increase the width of a span. To achieve an outer span width of 9 with a prefix of 1, you should set the span to 8 and then add the prefix.

  2. Relative padding is calculated based on the parent element's width, not the current element's width. Therefore, when using span-columns along with pad or prefix, make sure to pass the same context argument. The corrected code snippet should be:

    .image-group-title
      +span-columns(10, 14)
      padding: 1em 0
      +prefix(1, 14)
      +trailer(.5)
    

It seems unclear from your example which code applies to the p in question, making it difficult to provide an accurate answer. Nonetheless, I hope these insights prove helpful.

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

Change the background color of the top element box when scrolling

The code I have implemented reflects my intentions. html: <div id="one" class="box"></div> <div id="two" class="box"></div> <div id="thr" class="box"></div> <div id="fou" class="box"></div> <div id="fiv" ...

Delay the .show class in Bootstrap 4 navbar collapse after disabling the .collapsing class

In Bootstrap 4 collapse functionality, I am looking to remove the delay in displaying the .show class after the .collapsing class. What I want is for the .show class to appear on the .collapse element immediately after a click event triggers the toggle. ...

Is there a way to apply styling to an SVG element using code before it is displayed using React?

Rendering my SVG in React is working fine render () { return ( <object type="image/svg+xml" data="./src/img/test.svg" ref="svg"> </object> ) } I am looking to allow the user to customize the fill color by selecting ...

Transform your CSS styles into Material-UI makestyles

I am looking to implement an IconButton with a website preview feature that appears when the user hovers over the help icon. I came across a similar solution using CSS, but I need to convert it to Material UI. Here is the CSS code that needs to be converte ...

What is the reason that CSS selectors cannot use numbers as IDs?

I have come to realize that numbers cannot be used in CSS selectors. <!DOCTYPE html> <html> <style type="text/css"> div{width:350px;word-wrap:break-all; } #1{float:left;} </style> <div class="up"> <p><img id= ...

Building a bespoke search input for the DataTables JQuery extension

As the title indicates, I am in the process of developing a custom search box for the DataTables JQuery plugin. The default options do not suit my needs, and configuring the DOM is also not ideal as I aim to integrate it within a table row for display purp ...

Top-notch java tool for caching and minifying dojo, jquery JavaScript, and CSS files

In our project, we have downloaded the Dojo and jQuery libraries from Google CDNs. I am currently seeking a Java tool that can both cache and minify these libraries. The caching process should take place within the ROOT project of Tomcat. While I am awar ...

Material UI - Array of Chips

I have been working on creating a ReactJS component that displays an array of chips with unique styling for each one. To achieve this, I created individual makeStyles classes for the chips. However, I encountered difficulties in dynamically changing the cl ...

Tips for optimizing HTML and CSS for better browser performance

Just starting to learn HTML, CSS through an online course and currently working on a simple website. The table of contents on my website is centered, but when I resize the browser on my 27-inch iMac, it doesn't stay centered. Any tips? Here's a s ...

Using JQuery to retrieve part of a className results in a null value being returned

I am facing an issue with a piece of code in codesandbox where it returns null when I attempt to retrieve part of the className from a div using JQuery. How can I troubleshoot this and make it work? Check out the Codesandbox Example import React, { Compo ...

In Chrome, there is a single pixel missing below the <dl> element

While my website's basic list looks great on Firefox and IE, there seems to be one missing pixel line in Chrome. Check out this JsFiddle link shared by Jared in the comments for reference. If you're not seeing the missing line, try adjusting th ...

Why Does My Bootstrap Borderless Table Still Show a Border?

Just starting out with Boostrap and struggling to identify what might be causing this issue on my Create view and how to resolve it. https://i.sstatic.net/nWNkc.jpg Below is the relevant section of my view: <h3 class="text-primary pl-3"> ...

Avoid changing the orientation

Despite having a similar title, my question is not a duplicate of Prevent orientation change in iOS Safari. I have modified the code provided below. I have written the following code to automatically rotate the content when a user rotates their iPad/iPhon ...

Faulty Container - Excessive spacing issues

https://i.sstatic.net/Sp23W.png Currently enrolled in a Udemy course on Full Stack Development from scratch. The instructor often makes mistakes that require improvisation, like using <span> instead of <p> next to the sign-in. Additionally, ad ...

Do styled components have the capability to perform calculations similar to SCSS?

Using SCSS, I have the power to work wonders with CSS: @for $i from 1 through $total-items { li:nth-child(#{$i}) { animation-delay: .25s * $i; } } I am currently developing a React App that utilizes styled components. Is it possible to achieve th ...

Looking for solutions to issues with Style errors and Visibility problems?

< table border="1" cellpadding="0" cellspacing="0" width="100%"> < tr> < td>1< /td> < td>1< /td> < td>1< /td> < td>1< /td> < td>1< /td> ...

Update the text within a textarea by clicking with the power of jquery

Is there a way to clear the content of my textarea on click? Below is the code snippet: http://jsfiddle.net/QMfyP/ <textarea name="adventage" style="width:400px; border-radius: 3px; border-left: 4px solid #6C3" id="adventage" cols="45" rows="5">Sh ...

The text element does not line up with the icons

As I'm working on creating my first account page header, I've run into an issue with some of the icons not aligning perfectly with the text. While advanced developers may find this task simple, as a beginner, I could really use some advice on how ...

Properly implement CSS to ensure text responds effectively across different devices

I need some help reducing the size of my commerce titles in the responsive version. I've tried using CSS, but nothing seems to be working. Currently, this is what I have for the main slider text: @media only screen and (max-width: 600px) {.zphero-bann ...

In ReactJS with Bootswatch, the font styles are not applied

I have experimented with various methods to apply this font, but it is still not functioning correctly. @font-face { font-family: 'Samim'; src: local('Samim'), url(./resources/fonts/Samim.ttf) format('truetype'); fon ...