0

我有一个 wordpress 网站,我试图在滑块图像上垂直浮动文本。

我使用以下 CSS 在我的滑块小部件上硬编码了一个静态全宽图像。

.slider-wide {
clear: both;
width: 100%;
height: 560px;
    background: url(http://photourl);
background-position: center;
background-repeat: no-repeat;
background-size: cover; 

}

现在来回答这个问题。虽然文本在宽屏上看起来很漂亮,但当浏览器窗口缩小或从移动设备查看时,文本会溢出滑块图像并溢出到其他小部件中。

有没有办法将此文本锁定到仅滑块小部件中?以某种方式响应文本大小?

4

1 回答 1

0

是的,如果您使用viewport units ,您可以在文本上使用“响应式”文本大小。

这种单位支持的值之一是百分比值,基于容器的宽度、高度或两者……这是一个概念示例:http: //jsfiddle.net/t7b8ytrq/

{
    font-size: 2vh; /* size based on container's height */
    font-size: 2vw; /* size based on container's width */
    font-size: 2vmin; /* size based on witchever is smaller (width or height) */
    font-size: 2vmax; /* size based on witchever is higher (width or height) */
}

在此处阅读规格:http: //dev.w3.org/csswg/css-values/#viewport-relative-lengths

于 2014-08-25T16:32:58.337 回答