简体   繁体   中英

I can't get a background image to repeat vertically with CSS/HTML

I cant get my background image to repeat vertically using CSS and HTML. My HTML looks like this:

<div style="stack">
<img src="http://i.imgsafe.org/370409f.png" style="background-repeat:repeat-y;
width:120px;height:100px;alt="sunflower"> &nbsp
</div>
width:120px;height:100px;alt="sunflower"> &nbsp
</div>

And my CSS looks like this:

.stack {
background-image:url(http://i.imgsafe.org/370409f.png)
background-repeat:repeat-y;
}

It's kind of unclear what your code is trying to do, you have broken HTML and CSS in just about everything. You should run your code through a validator and it will tell you everything that is broken. But here's the general concept. Mainly just change style="stack" to class="stack" and then put your CSS in a CSS file and remove all of the broken inline style attribute stuff.

 .stack { background: url(http://i.imgsafe.org/370409f.png) 0 0 repeat-y; height: 1000vh; } 
 <div class="stack"> </div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM