Setting size for icon in CSS

前端 未结 6 1136
再見小時候
再見小時候 2021-01-31 15:54

I\'m working on JSF, and I\'m using this code to display an error box.

相关标签:
6条回答
  • 2021-01-31 16:33

    Funnily enough, adjusting the padding seems to do it.

    .arrow {
      border: solid rgb(2, 0, 0);
      border-width: 0 3px 3px 0;
      display: inline-block;
    }
    
    .first{
      padding: 2vh;
    }
    
    .second{
      padding: 4vh;
    }
    
    .left {
        transform: rotate(135deg);
        -webkit-transform: rotate(135deg);
     }
    <i class="arrow first left"></i>
    <i class="arrow second left"></i>

    0 讨论(0)
  • 2021-01-31 16:37

    You could override the framework CSS (I guess you're using one) and set the size as you want, like this:

    .pnx-msg-icon pnx-icon-msg-warning {
        width: 24px !important;
        height: 24px !important;
    }
    

    The "!important" property will make sure your code has priority to the framework's code. Make sure you are overriding the correct property, I don't know how the framework is working, this is just an example of !important usage.

    0 讨论(0)
  • 2021-01-31 16:41

    you can change the size of an icon using the font size rather than setting the height and width of an icon. Here is how you do it:

    <i class="fa fa-minus-square-o" style="font-size: 0.73em;"></i>
    

    There are 4 ways to specify the dimensions of the icon.

    px : give fixed pixels to your icon

    em : dimensions with respect to your current font. Say ur current font is 12px then 1.5em will be 18px (12px + 6px).

    pt : stands for points. Mostly used in print media

    % : percentage. Refers to the size of the icon based on its original size.

    0 讨论(0)
  • 2021-01-31 16:56

    The better way is using 'background-size'.

    .pnx-msg-icon .pnx-icon-msg-warning{
    background-image: url("../pics/edit.png");
    background-repeat: no-repeat;
    background-size: 10px;
    width: 10px;
    height: 10px;
    cursor: pointer;
    }
    

    even if your icon dimensions is bigger than 10px it will be 10px.

    0 讨论(0)
  • 2021-01-31 16:57

    None of those work for me.

    .fa-volume-down {
        color: white;
        width: 50% !important;
        height: 50% !important;
        margin-top: 8%;
        margin-left: 7.5%;
        font-size: 1em;
        background-size: 120%;
    }
    
    0 讨论(0)
  • 2021-01-31 16:58

    this works for me try it.

    height:1rem;
    font-size: 3.75em;
    
    0 讨论(0)
提交回复
热议问题