(CSS) How position text (with background color) over

后端 未结 2 704
甜味超标
甜味超标 2021-01-25 05:54

As the title says

my code is something like this :

some text with line one, line two , line three <
2条回答
  •  再見小時候
    2021-01-25 06:37

    I see no reason not to use position: absolute.

    See: http://jsfiddle.net/NeaR4/

    CSS:

    .container {
        border: 2px dashed #444;
        float: left;
        position: relative
    }
    .container img {
        display: block
    }
    .container > div {
        position: absolute;
        left: 0;
        bottom: 0;
        right: 0;
        height: 14px;
        background: #000;
        background: rgba(0,0,0,0.7);
        color: #fff;
        overflow: hidden;
        font: bold 14px Arial, sans-serif;
        padding: 5px;
    }
    .container:hover > div {
        height: auto
    }
    

    HTML:

    some text with line oneeee, line twoooooooo ooooooo , line three

提交回复
热议问题