How can I do width = 100% - 100px in CSS?

前端 未结 18 855
借酒劲吻你
借酒劲吻你 2020-12-12 13:28

In CSS, how can I do something like this:

width: 100% - 100px;

I guess this is fairly simple but it is a bit hard to find examples showing

18条回答
  •  遥遥无期
    2020-12-12 13:51

    Are you using standards mode? This solution depends on it I think.

    If you're trying to make 2 columns you could do something like this:

    sidebar
    lorem ispsum etc...

    Then use CSS to style it:

    div#outer
    {
        width:100%;
        height: 500px;
    }
    
    div#left
    {
        width: 100px;
        height: 100%;
        float:left;
        background: green;
    }
    
    div#main
    {
       width: auto;
       margin-left: 100px; /* same as div#left width */
       height: 100%;
       background:red;
    }
    

    If you don't want 2 columns you can probably remove

提交回复
热议问题