skip to Main Content

I’m trying to make a 90s styled website, and I need to set the wideness of a div with .padding-side to calc(100% - 20px), but it won’t work.

I tried doing the following:

[style.css]

.padding-side{
  padding:0px 10px;
  .wide{
    width:calc(100% - 20px) !important;
  }
}

It didn’t work. I tried:

.padding-side & .wide{
  padding:0px 10px;
  width:calc(100% - 20px);
}

But it didn’t work.

2

Answers


  1. To add a CSS rule for a element that has two classes you can do this:

    .padding-side.wide {
      padding: 0px 10px;
      width: calc(100% - 20px);
    }
    

    Or if you want to always have the padding on the .padding-side class and if a element has both classes to set the width you can do this.

    .padding-side {
      padding: 0px 10px;
      &.wide {
        width: calc(100% - 20px);
      }
    }
    

    But the browser support for this is not perfect.

    Login or Signup to reply.
  2. Probably your parent .padding-side needs to have width: 100%; This is needed in case that .padding-side is not block level element.

    .padding-side{
      padding:0px 10px;
      width: 100%;
      .wide{
        width:calc(100% - 20px) !important;
      }
    }
    

    If this is not working, then try adding width: 100% to other parent elements.
    I you can provide whole html + css we can get you better answer.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search