• html用法总结


    margin-right无效解决方法

    我们在设置盒子样式或者位置的时候会遇到margin-right没有效果。要怎么解决呢?首先要观察一下设置margin-right的元素有没有设置width属性,width的属性值是什么。

    当没有设置width时,width默认为auto:
    这时的margin-right是正常显示的;

    当width设置为固定值或者百分比时:
    margin-right在默认文档标准流中是无效的,要想显示出效果,必须要脱离文档标准流,可以用下面的方法恢复margin-right的效果:

    float:left | right;
    设置position;
    设置display;

    margin-bottom无效解决方法

    一:定位
    margin-bottom是指该元素与其后的兄弟节点之间的距离。如果你在m1下面再加上一行p标签,你会看到,p距离m1之间的距离,就是m1的margin-bottom的值。最外层那个id为box的div,是m1的父级节点,m1的margin-bottom是不会对box产生效果的。
    如果要使一个节点相对于某个节点固定在指定位置,应该是bottom(以及top、left和right)属性,但这个要求该节点的position属性是absolute(即绝对定位),且其父节点的position属性为relative(相对定位),则该几点即可相对其父节点定位。比如:

    相对父节点定位

    则,上面的p标签就会距离父级div底部10px,距离右端20px。

    二:给父节点一个margin-bottom也可间接实现
    给父级设置:

     margin-right: 0px;
     overflow:hidden;
      zoom:100%;
    
    • 1
    • 2
    • 3
    .panel-item{
        margin-right: 0px;
        overflow:hidden;
        zoom:100%;
    }
    #cont table{
        width: 100%;
        height: 100%;
        margin-top: 10px;
        margin-left: 12px;
        margin-bottom: 12px;
        background-color: papayawhip;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    margin-right、margin-bottom设置不起作用?

    可能是浏览器默认是从左向右渲染
    一个div .box默认是左上对齐,所以margin-right、margin-bottom设置不起作用

    实现鼠标悬浮

    鼠标靠近显示图片,离开隐藏
    在这里插入图片描述

    //在li标签中直接用img无效果,暂时没找到原因,所以用的背景图代替
     <div class="hover">
        <ul class="ul-one">
             <li class="li li-one"></li>
             <li class="li li-two"></li>
             <li class="li li-three"></li>
         </ul>
     </div>
    
    
    .hover{
        position: absolute;
        right: 0px;
        top: 0px;
        height: 100%;
    }
    .ul-one {
        margin-top: 24px;
    }
    
    .hover li {
        margin: 8px 0px;
        width: 26px;
        height: 20px;
    }
    .hover .li-one:hover{
       background: url('../../images/monitor/tip.png') no-repeat 5px 0px;
       background-color: #D9E7FF;
       border-top-left-radius: 1em;
       border-bottom-left-radius: 1em;
    }
    .hover .li-two:hover{
        background: url('../../images/monitor/time.png') no-repeat 5px 0px;
        background-color: #D9E7FF;
        border-top-left-radius: 1em;
        border-bottom-left-radius: 1em;
     }
     .hover .li-three:hover{
        background: url('../../images/monitor/echart.png') no-repeat 5px 0px;
        background-color: #D9E7FF;
        border-top-left-radius: 1em;
        border-bottom-left-radius: 1em;
     }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
  • 相关阅读:
    掌握这些PDF转Word方法,从此你就是大神的存在
    ROS1云课→24机器人感知配置
    不可重复读和幻读详解(必看!!!)
    python开发数字人助理版
    深入理解rtmp(一)之开发环境搭建
    蓝桥杯动态规划每日一题
    Java设计模式七大原则-里氏替换原则
    网络编程中利用信号处理技术消灭僵尸进程
    11809 - Floating-Point Numbers (UVA)
    (02)Cartographer源码无死角解析-(13) 开始轨迹→Node::AddTrajectory()
  • 原文地址:https://blog.csdn.net/hnn567/article/details/126059162