html - 图像停留上的简单 CSS 文本

标签 html css

您好,我想在图像上显示这段文字。我希望文本位于两个人的左侧,并在我的媒体查询中从桌面 View 移动到平板 View 时与图像保持比例 enter image description here

这是我的HTML

<figure><img src="Sources/USE/colors.png">

    <figcaption><h1>Your P<span class="orange">a</span>rtner in<br><br><span class="all"="colorstxt"><span class="green">C</span><span class="yellow">o</span><span class="orange">l</span><span class="red">o</span><span class="pink">r</span><span class="purple">s</span></h1></figcaption>

    </figure>

这是我的 CSS

#hero_container figure{
    position: static;
    }   

#hero_container figure figcaption{
    position: relative;
    top: 200px;
    left: 100px;
    }

我试图让它定位为绝对和相对,但是它使页面的其余部分跳到图像下方。任何有关简单问题的帮助将不胜感激。

最佳答案

你快到了......

使figure position: relative; 和标题绝对定位。

#hero_container figure{
    position: relative;
    }   

#hero_container figure figcaption{
    position: absolute;
    bottom: 10%;
    left: 10%;
    }

关于html - 图像停留上的简单 CSS 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29849894/

相关文章:

php - CSS 导致 SQL INSERT 执行两次

html - 我无法将谷歌字体和天气小部件添加到 Github 页面

html - 垂直对齐 block 级元素,水平宽度为 90%

jquery - 调整字体大小以适应 div(在一行中)

javascript - 将数据发布到 .html 时如何隐藏 JQuery 中的元素?

css - 如何在不使用固定定位的情况下使视口(viewport)的 div 达到 100%?

javascript - 使用outerHeight();测量相同的类名,但高度不同

javascript - "zoom"/"scale"如何用css 或jquery 在div 的内容?

javascript - LocalStorage 将属性 'innerHTML' 设置为 null。尝试使用 window.onload 解决方案

javascript - 记住在 css 中所做的更改