gpt4 book ai didi

css - 纯CSS移动div元素的背景图片

转载 作者:行者123 更新时间:2023-11-28 18:15:31 25 4
gpt4 key购买 nike

我正在尝试使用纯 CSS 移动 div 元素的背景图像。在这里,我从用户那里输入背景图像 url,这就是为什么我不能在 CSS 中声明它。我也不能将其声明为固定位置或绝对位置的图像,因为它会影响我其余的 CSS。有没有办法只为div元素的背景写CSS?

fiddle - jsfiddle.net/ZTsG9

HTML:

<div class="view" style="background-image: url('http://css3slideshow.remabledesigns.com/1.jpg')">According to a new report from AnandTech, Samsung might be fibbing its way to more favorable Galaxy S4 benchmarks. Has your device suddenly come to a crawl? Of course it hasn’t; benchmarks shouldn’t change your perception of a flagship as powerful as the S4. Still, it’s embarrassing that Samsung would resort to such technical tactics, like allegedly using code dubbed “BenchmarkBooster.” Yes, your device takes steroids.</div>

CSS:

.view {
position:relative;
height:100%;
width:100%;
top:0;
left:0;
animation:mymove 5s infinite;
-webkit-animation:mymove 5s infinite;
/* Safari and Chrome */
}
@keyframes mymove {
from {
left:0px;
}
to {
left:200px;
}
}
@-webkit-keyframes mymove
/* Safari and Chrome */
{
from {
leftp:0px;
}
to {
left:200px;
}
}

最佳答案

您需要做的是添加 background-position: x, y 其中 x 和 y 等于您要放置元素的位置的长度和高度。 http://www.w3schools.com/cssref/pr_background-position.asp

<div class="view" style="background-image: url('http://css3slideshow.remabledesigns.com/1.jpg') background-position:50px 20px;">
According to a new report from AnandTech, Samsung might be fibbing its way to more favorable Galaxy S4 benchmarks. Has your device suddenly come to a crawl? Of course it hasn’t; benchmarks shouldn’t change your perception of a flagship as powerful as the S4. Still, it’s embarrassing that Samsung would resort to such technical tactics, like allegedly using code dubbed “BenchmarkBooster.” Yes, your device takes steroids.</div>

关于css - 纯CSS移动div元素的背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17977154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com