Vertically Stretch Background Image - Css - Stack Overflow
Có thể bạn quan tâm
-
- Home
- Questions
- Tags
- Users
- Companies
- Labs
- Jobs
- Discussions
- Collectives
-
Communities for your favorite technologies. Explore all Collectives
- Teams
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Try Teams for free Explore Teams - Teams
-
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about TeamsGet early access and see previews of new features.
Learn more about Labs Vertically stretch background image Ask Question Asked 12 years, 2 months ago Modified 3 years ago Viewed 57k times 33I am trying to figure out how to stretch a background image vertically. I am using CSS3 with 3 images in the following way:
background-image: url("left.png"), url("right.png"), url("center.png") background-repeat: no-repeat, no-repeat, repeat-x background-position: top left, top right, topNow I want to stretch these images vertically to that they extend all the way to the bottom. Is there a way to do this?
Share Improve this question Follow edited Oct 2, 2012 at 16:56 user1539137 asked Oct 2, 2012 at 16:40 user1539137user1539137 3691 gold badge4 silver badges5 bronze badges 3- I don't think so. You can resize (stretch/squish) <img> tags, though: the solution may involve putting an <img> in the background, positioned absolutely and such. – KRyan Commented Oct 2, 2012 at 16:42
- 1 This might be a good place to look: stackoverflow.com/questions/1150163/… – MikeB Commented Oct 2, 2012 at 16:42
- 1 Also, pretty sure you're not supposed to put quotes around your urls like that. – KRyan Commented Oct 2, 2012 at 16:43
3 Answers
Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 54I'm late to the party here, but this is what worked for me:
background-size: auto 100%;This will fit the image vertically and let the width do whatever it needs to do (i think it repeats by default). You can also set:
background-repeat: no-repeat;for it to not repeat the image in the horizontal direction.
Share Improve this answer Follow answered Nov 18, 2013 at 19:48 mr_mariuszmr_mariusz 6648 silver badges12 bronze badges 2- 1 I also needed to set background-position: center; – KIC Commented May 4, 2015 at 15:59
- 2 background-size: cover; is worth exploring – nu everest Commented Oct 19, 2017 at 23:37
Try:
background-size: 100% 100%;first 100% is for the width and the second for the height. In your case you need the second set to 100%
Share Improve this answer Follow edited Oct 7, 2013 at 19:16 LihO 42k11 gold badges101 silver badges168 bronze badges answered Oct 2, 2012 at 16:45 Erind DollakuErind Dollaku 3692 silver badges9 bronze badges 2- 1 How do I just set the height to 100%? If I do background-size: 100%, it sets both width and height to a 100%. – user1539137 Commented Oct 8, 2012 at 12:37
- 2 This was pretty handy. In my case, I set "background-size: 960px 100%;" to get the desired effect. – Jason Champion Commented Jul 15, 2013 at 20:04
Thank you for bringing up this question. Below is what worked for me
background-size: cover; background-color: #a8dadc; background-repeat: no-repeat; background-size: 100vw 100vh; Share Improve this answer Follow edited Nov 8, 2021 at 4:40 Dharman♦ 33.1k27 gold badges99 silver badges146 bronze badges answered Nov 8, 2021 at 4:34 Nadine AmandaNadine Amanda 11 bronze badge Add a comment |Your Answer
Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Draft saved Draft discardedSign up or log in
Sign up using Google Sign up using Email and Password SubmitPost as a guest
Name EmailRequired, but never shown
Post Your Answer DiscardBy clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Not the answer you're looking for? Browse other questions tagged
or ask your own question.- The Overflow Blog
- Your docs are your infrastructure
- Featured on Meta
- More network sites to see advertising test [updated with phase 2]
- We’re (finally!) going to the cloud!
Linked
939 Stretch and scale a CSS image in the background - with CSS only -1 How to stretch background from top to bottom? 1 background sizing to screen without image distortionRelated
192 Stretch background image css? 2 stretching background image 0 CSS vertical stretch to background 0 Need help stretching background image vertically 7 CSS Stretched Background Image 1 CSS - Background Image Stretch 0 Background-image stretch 1 Stretch a part of background image 0 Stretch CSS Background Image 0 CSS3 background image doesn't vertically stretchHot Network Questions
- Deutsche Bahn Berlin: can I use a different departure station?
- What was the significance of Mount Doom's eruption?
- Understanding the definition of the covariant derivative
- A roulette wheel? An AC Milan kit? Darth Maul's face?
- Why is Ukraine's conscription age (still) so high (25)?
- Does ambigous license without a version refer to most recent? Is 'AGPL' currently equivalent to 'AGPL-3.0-only'?
- What mechanism could cause a person not to cast a reflection?
- Why is Anarchism not considered fundamentally against the "democratic order" in Germany?
- How do I go about rebranding a fully deleted project that used to have a GNU General Public License v3.0 but is now fully inaccessible
- How much do ebikes actually benefit from ebike specific wheels, tires, and forks?
- Is there a symbol for the Hyper key?
- What's the Purpose of the IRQ on a 6502
- Find the Smallest Data Type for a Number
- Can a ML model learn the hyperparameters landscape?
- If scent means a pleasant smell, why do we say "lovely scent" or "sweet scent"?
- BIOS drive order is inverse of Windows'
- What happens when a ranger uses Favored Foe with Hunter's Mark?
- Conditional Definition of a Mathematical Operator
- Why does Jesus tell the Jews to follow the Pharisees teaching while elsewhere He speaks of them creating unnecessary rules?
- Can Martial Characters use Spell Scrolls in D&D 2024?
- Is there a commonly used expression for adjusting a training or form of support to a person's specific situation and needs?
- Shell Script to Normalize the data
- Is there evidence that Kurt Gödel took his proof of the existence of God to be conclusive?
- A fantasy story with an imp in a box that paints pictures
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
defaultTừ khóa » Html Background Image Stretch Vertically
-
How To Stretch And Scale An Image In The Background With CSS
-
HTML Stretch Background Image
-
How To Stretch A Background Image To Fit A Web Page - ThoughtCo
-
Css Stretch Image To Fit Vertically Code Example
-
Background-size - CSS: Cascading Style Sheets - MDN Web Docs
-
Resizing Background Images With Background-size - CSS
-
How To Make An Image Stretch Vertically Css?
-
How To Repeat Background Image Vertically And Horizontally Using CSS
-
Background-size - CSS-Tricks
-
CSS Background-repeat Property - W3Schools
-
CSS Background-size Property - W3Schools
-
Stretch Background Image In Header Only Horizontally, It Does Not ...
-
Background Size - Tailwind CSS
-
Can't Stretch Background Image - General - Forum | Webflow