1

is there a way to make a div not scalable?

This is my css:

.card{
margin-left:5px;
width:19%;
float:left;
}

I want the div card to stay the same width even when you scale the browser.

Elvira
  • 1,410
  • 5
  • 23
  • 50

4 Answers4

0

Use a percentage only if the container of your div element has a fixed width in pixels. Or, as Oriol told you, use a fixed width for your div

n1kkou
  • 3,096
  • 2
  • 21
  • 32
0

If you just set your width using px and not % it will max it to that width

Fiddle

SaturnsEye
  • 6,297
  • 10
  • 46
  • 62
  • This does not work if the width should be always 1/5 of the screen width... I have the same problem with a sticky top menu having width:100%, but I don't want to have it scalable... – basZero Jul 10 '15 at 11:57
0

The width property

specifies the content width of boxes.

It can have those values:

  • <length>: Specifies the width of the content area using a length unit.
  • <percentage>: Specifies a percentage width. The percentage is calculated with respect to the width of the generated box's containing block.
  • auto: The width depends on the values of other properties.

You are using a percentage. Use a fixed length instead:

The format of a length value is a <number> (with or without a decimal point) immediately followed by a unit identifier (e.g., px, em, etc.).

Oriol
  • 274,082
  • 63
  • 437
  • 513
0

You could target children of a parent no to scale by css selectors, but you cant disable scaling as a property on a single element unfortunately.

#parent > span:not(:last-child){
    -moz-transform: scale(0.5);
    -webkit-transform: scale(0.5);
    -ms-transform: scale(0.5);
    transform: scale(0.5);
    display:block;
}

See this Answer

JasParkety
  • 131
  • 1
  • 6