• CSS Notes


    Margin vs. Padding
    Margin is on the outside of block elements while padding is on the inside. Use margin to separate the block from things outside it. Use padding to move the contents away from the edges of the block. Enter image description here:
    enter image description here
    When elements needs space between them, better to use margins. When text or an inner element needs space between the parent box and itself go for paddings.

    Width & Height
    When you set the width and height properties of an element with CSS, you just set the width and height of the content area. To calculate the full size of an element, you must also add the padding, borders and margins.

    /* It will only have effect on the link in this page */

    #this-page a:hover {
        ...
    }

    nth-child

    You can actually select any child of an element after the first child with the pseudo-class selector nth-child; you just add the child's number in parentheses after the pseudo-class selector. For example,

    p:nth-child(2) {
        color: red;
    }

    would turn every paragraph that is the second child of its parent element red. The element that is the child goes before :nth-child; its parent element is the element that contains it.


    Hover to show underline
    You'll most often use this selector when applying, for example, a border-bottom to anchor tags, when hovered over.

    a:hover {
        border-bottom: 1px solid black;
    }

    Pro-tip - border-bottom: 1px solid black; looks better than text-decoration: underline;.

  • 相关阅读:
    Mac 上所有的命令行相关问题的总结
    ThinkPHP中的统计查询方法
    织梦任意页面调用{dede:field.content/}的方法
    PHP isset()、empty()、is_null()的使用区别详解
    Dede更新提示DedeTag Engine Create File False的解决办法
    cookie 和session 的区别
    织梦后台如何设置手机站
    PHP时间戳和日期转换
    dede列表页调用
    dede图集内容页调用
  • 原文地址:https://www.cnblogs.com/null00/p/3923724.html
Copyright © 2020-2023  润新知