简体   繁体   中英

CSS center background image horizontally AND THEN repeat vertically?

I have a small challenge that I was hoping you could help me out with. I am trying to center a very wide image (2500x20) on the background and have it tile (repeat) down... I can find lots of info on how to center both ways... or how to repeat both ways... but nothing on how to mix the two. Is this even possible?

background: url(http://placehold.it/2500x20) repeat-y center;

演示: http//cssdesk.com/CatAa

.foo {
    background-position: 50% 0; /* centers the image horizontally */
    background-repeat: repeat-y; /* tiles it vertically */
}

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