Search code examples
csscalc

How to transform percentage to pixels CSS for bottom parameter?


I got this in my css file:

#myClass {
    position: absolute;
    height: 6px;
    width: 100%;
    bottom: 66%;  <<  here is 66%
    left: 0;
    right: 0;
    background-color: #666;
    cursor: n-resize;
}

There is the bottom percentage 66%

But I need something like this:

bottom: ~calc(66% - 35px);

or this

bottom: calc(66% - 35px);

But that didn't work!

Can you help me?


Solution

  • if it should be 66% of the height, try:

    bottom: calc(66vh - 35px);
    

    or if it should be 66% of the width, try:

    bottom: calc(66vw - 35px);