zoukankan      html  css  js  c++  java
  • Html 让文字显示在图片的上面

    如题:

    第一种方式便是将 image 作为背景图片,即:background-image:url(".......");

    在此可以控制背景图片的横向和纵向的平铺:

    background-repeat : none;  不进行平铺

    background-repeat : repeat-x;  横向x轴进行平铺

    background-repeat : repeat-y;  横向y轴进行平铺

    background-repeat : repeat;  横向x轴与纵向y轴都进行平铺,这也是默认情况的状态

    第二种方式是将img块与文字块放在同一个div 中,然后设置他们之间的位置,例如如下代码块:

    <div style="position:relative;">

      <img src="...." />

      <div style="position:absolute; z-index:2; left:10px; top:10px">

        haha

      </div>

    </div>

    其余的位置再根据实际情况进行微调就好~~

    关于position中relative 以及 absolute 属性值的区别:

    position:absolute这个是绝对定位;
    是相对于浏览器的定位。
    比如:position:absolute;left:20px;top:80px; 这个容器始终位于距离浏览器左20px,距离浏览器上80px的这个位置。

    position:relative是相对定位,是相对于前面的容器定位的。这个时候不能用top left在定位。应该用margin。

    比如:<div class="1"></div><div class="2"></div>

    当1固定了位置。1的样式float:left;100px; height:800px;
    2的样式为float:left; position:relative;margin-left:20px;50px;
    2的位置在1的右边,距离120px

    更多请看: http://net08118.blog.163.com/blog/static/11011170420129193741264/ 

       http://blog.csdn.net/chhuma/article/details/7484940 

    如果想限制img 标签的最大宽高,可以用max-width 和 max-height 这两个属性,如下代码:

    <img src="......" style="max-100px; max-height:100px" />

  • 相关阅读:
    流程控制
    小结
    运算符
    进制之间的转换
    自动类型转换和强制类型转换
    变量
    关键字,标识符,
    NGINX 做TCP转发(端口转发)并记录日志
    redash安装
    解决 es CircuitBreakingException 问题(Data too large Error)
  • 原文地址:https://www.cnblogs.com/jpfss/p/7755736.html
Copyright © 2011-2022 走看看