Background images with HTML & CSS

Sdílet
Vložit
  • čas přidán 30. 07. 2024
  • In this video, I look at how to set a background image, problems people run into with them and how to fix them, and finish things off with a bonus tip on readability.
    🔗 Links
    ✅ How to select things in your CSS: • HTML & CSS for Beginne...
    ✅ Why you should use Firefox when learning CSS: • Stop using Chrome if y...
    ✅ How I update the browser on save: marketplace.visualstudio.com/...
    ✅ How to control your background-images: • Controlling background...
    ⌚ Timestamps
    00:00 - Introduction
    00:47 - Don't have the images in your HTML
    01:29 - Use an external CSS file
    03:45 - Linking a background image in an external CSS file
    05:58 - Fallback background-color
    06:45 - Don't use heights
    08:21 - When the image doesn't show up
    10:43 - background-repeat
    12:26 - When an image is too big
    14:36 - Making an image fit
    16:59 - BONUS - making the text readable
    #css
    --
    Come hang out with other dev's in my Discord Community
    💬 / discord
    Keep up to date with everything I'm up to
    ✉ www.kevinpowell.co/newsletter
    Come hang out with me live every Monday on Twitch!
    📺 / kevinpowellcss
    ---
    Help support my channel
    👨‍🎓 Get a course: www.kevinpowell.co/courses
    👕 Buy a shirt: teespring.com/stores/making-t...
    💖 Support me on Patreon: / kevinpowell
    ---
    My editor: VS Code - code.visualstudio.com/
    ---
    I'm on some other places on the internet too!
    If you'd like a behind the scenes and previews of what's coming up on my CZcams channel, make sure to follow me on Instagram and Twitter.
    Twitter: / kevinjpowell
    Codepen: codepen.io/kevinpowell/
    Github: github.com/kevin-powell
    ---
    And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Komentáře • 225

  • @imheretofiremylazeh
    @imheretofiremylazeh Před 2 lety +117

    Not only good content and info, but also good presentation and sound quality. Every video is a gem

  • @BenjaminAster
    @BenjaminAster Před 2 lety +58

    Don't forget your , otherwise the browser doesn't load the image before the entire CSS file is loaded and parsed. This can be very slow; especially at 3G connections.

  • @lizflaggswope4747
    @lizflaggswope4747 Před 2 lety +26

    Kevin,
    I'm just learning CSS, and your videos are SO encouraging and refreshing! Thank you for making it all so approachable!

  • @nathanwatts76
    @nathanwatts76 Před 2 lety +3

    Your timing could not be better! I literately just came to your channel to find this exact topic. Keep up the good work champion.

  • @albertoa.r.5995
    @albertoa.r.5995 Před 2 lety +1

    I love when you go back to basics. Somehow it helps also to grasp advanced concepts that rely on this. Thanks!

  • @johannarodriguez3573
    @johannarodriguez3573 Před rokem

    you blew my mind with background-blend-mode, none of all the courses I've done mentioned it. How cool I found your video, thanks!!!

  • @nataliadi9
    @nataliadi9 Před 2 lety +1

    Kevin, I am so happy I came across with your channel. You do make people fall in love with css. It really makes me stay curious. Thank you!

  • @MartynKoi
    @MartynKoi Před 2 lety +7

    I have used a container for the text with a dark semi transparent background. This allows the image to show through and also a darker patch for the lighter text to be displayed. It has the advantage of framing the text which I think is a great eye catching feature if done right. Just my little tip :) Great video again, well done.

  • @reginamurguia4078
    @reginamurguia4078 Před rokem +6

    Love your content, please keep it up! The way you explain things with such a calm and practicity from the most basic aspect is very conforting and encouraging for everyone, even if you're only looking for a quick fix or tip. ❣

  • @justpeachyrl
    @justpeachyrl Před rokem +1

    Thank you so much, Kevin. I really really appreciate the care, attention to detail, and focus on best practices that you put into each of your videos.

  • @bukkorossu
    @bukkorossu Před 2 lety +3

    The bonus tip of that "background-blend-mode" property was pretty cool!

  • @IamPetrus
    @IamPetrus Před rokem +1

    Man, I have been over two hours of crazy frustration trying to figure out what was going on (swearing for granted) with my background - image, and in ten minutes of your video I could find the solution. Its the Kevin thing making it easy to us. Again!...

  • @Fahimurr
    @Fahimurr Před 2 lety +7

    Brilliant video, thank you Kevin for all your hardwork. Your videos are really helpful for someone like me who is getting into web dev.

  • @janman7419
    @janman7419 Před rokem

    Very helpful, and nicely explained! I am just getting into CSS, and just by pausing and peeking at your code I learned other additional things I did not know about. Maybe I should start to watch from the beginning of your series :D. Thank you very much

  • @JavierD
    @JavierD Před 2 lety +2

    It's so satisfying to find teacher with so much passion to teach. It's the best education anyone can get.

  • @swallowedinthesea11
    @swallowedinthesea11 Před rokem

    I knew most of these except the blending part. It will be very helpful! Thank you!

  • @abdulrhman2514
    @abdulrhman2514 Před 2 lety +1

    I hated working with CSS now I love it so much thanks to you
    Thank you Kevin!

  • @Ana-sm2nv
    @Ana-sm2nv Před rokem

    You are AMAZING! Great content and super clear. I think I am loving CSS! Thank you!

  • @gundi0012
    @gundi0012 Před rokem

    I watched the entire video for the blend mode tag thank you man i love your content

  • @andreyovedenie
    @andreyovedenie Před rokem

    Thank you!
    I watch some clips about this but your clip was full with all the information and that really help me!
    Again Thank you!

  • @frosty8104
    @frosty8104 Před rokem

    Nice tip about the blend mode.. I had no idea before that you could do that with css, though I knew about it from using it in Photoshop & Illustrator

  • @fabianpetersen2452
    @fabianpetersen2452 Před 2 lety

    Thanks Kevin, i was struggling with this recently and you made it super easy to understand 👍. Much love from South Africa

  • @eriklindestad9268
    @eriklindestad9268 Před 10 měsíci

    Thank you! I actually yelled out loud when you did the dot dot in the url because that's what I'd been missing all along.

  • @Cocodrillo3011
    @Cocodrillo3011 Před 8 měsíci

    Great video Kevin! This is exactly what i was looking for. Thank you!

  • @robynrooiland421
    @robynrooiland421 Před rokem

    First video that I watched, loved it, subscribed and reccomended to my friends.

  • @SeviersKain
    @SeviersKain Před rokem

    damn, that background-blend-mode is really working like a charm, thx Kevin !!!

  • @Webtricker
    @Webtricker Před 2 lety

    The background image tutorial with HTML & CSS was very nice and simple. It was good. Thanks for shearing.

  • @patrickmcnelis1520
    @patrickmcnelis1520 Před rokem

    Lol...I just had the path issue with your section styling video. Most important to double check those paths. And the inspect tip works very well. Thanks Kevin!

  • @aleksandraurban7867
    @aleksandraurban7867 Před rokem

    Thank you for this video! You explained so well and saved my life :D

  • @aleksandrasocha9508
    @aleksandrasocha9508 Před rokem

    This worked incredibly well! I can finally play it thanks

  • @Space_Curious
    @Space_Curious Před 3 měsíci

    Thank you so much for the last chapter of the video! I was searching for that since some hours ahaha

  • @Control4Daze
    @Control4Daze Před 2 měsíci

    Greatly appreciate your explanation and assistance! Thank you!

  • @annanagalina3567
    @annanagalina3567 Před 6 měsíci

    Thank you a lot! It helped me find the problem with my background image. Very detailed and clear explication.

  • @abrahamomorogieva8533

    the image being outside the folder was my problem. thanks so much, you earned a new subscriber

  • @Locklesh
    @Locklesh Před rokem

    Great video. Exactly what I needed. Thankyou.

  • @DanteMishima
    @DanteMishima Před 2 lety

    Thank you Kevin.
    I was just saying this to someone who is stuck in adding width and height, telling them to use padding

  • @raquelcampos2096
    @raquelcampos2096 Před rokem

    Thanks to teach responsiveness at the same time. I was adding a heigh every time I added a background picture , now I know better.

  • @kodeshare6273
    @kodeshare6273 Před 5 měsíci

    Thank you Kevin, you are always my go to guy for css.

  • @bogdandanila6306
    @bogdandanila6306 Před rokem

    Thank you so much for all your videos.I wish you good health and hope you are happy.

  • @mercedes7761
    @mercedes7761 Před rokem

    thank you so much for your detailed videos. I appreciate you!!

  • @MikeHerzog_de
    @MikeHerzog_de Před 2 lety

    Another nice tool to have in your box for legibility is `text-shadow`. In the white-text example from the video, I'd go with some dark color taken from the background image.

  • @Coco-ii2pu
    @Coco-ii2pu Před rokem

    Kevin is legit my CSS guardian angel. Thank you kev ❤️

  • @jonks5913
    @jonks5913 Před 2 lety

    thank you Kevin for this video this was driving me nuts looking for a solution

  • @abdulhadi_53
    @abdulhadi_53 Před rokem

    what I was looking for is to make it sticky background , So i found out by using background-attachment:fixed; and it worked very nice , and for a tip u can make shade on your background using background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.921), rgba(255, 255, 255, 0.914) ), url(" ./ your url for the bg ");
    And thank you kevin for the great work you are doing for make the web looking more aesthitic

  • @devprollc
    @devprollc Před rokem

    The video I didnt know I was looking for ^

  • @yankeesfan3961
    @yankeesfan3961 Před rokem

    Thank you for recommending Firefox as the main browser for web design. I like your instruction too. It's easy to understand as I right now am a very experienced beginner to whatever the next step is as a ranking.

  • @gokturkbuyuktuna8557
    @gokturkbuyuktuna8557 Před 5 měsíci

    Background-blend-mode was pretty helpful!!

  • @mofe620
    @mofe620 Před 2 lety

    Kevin...all your recent videos are solving my problems 🥺
    I need to check the past ones too

  • @zedricksalupito
    @zedricksalupito Před 11 měsíci

    Clear like Data I love this channel

  • @airNfinger
    @airNfinger Před 8 měsíci

    Sir, you just earned a new subscriber. This video was so helpful!!! Thank you.

  • @JackFate76
    @JackFate76 Před 2 lety

    This gives me so many memories.

  • @weareloved
    @weareloved Před rokem

    Thank you so much!! It was very helpful!!!👍🏼🙏🏻

  • @christopherkagan3242
    @christopherkagan3242 Před měsícem

    A great instructor with great t-shirts!

  • @daskeds
    @daskeds Před 2 lety

    Sir, you just have earned a lifelong subscriber

  • @archibaldsimms7440
    @archibaldsimms7440 Před 4 měsíci

    Hello Mr. Powell. Thank you so much for your videos. They have helped me a lot.

  • @priyadharshansenthil7343

    You are awesome sir 👏 through ur videos only I'm able to strong my front-end

  • @wargalevente
    @wargalevente Před 4 měsíci

    Hi Kevin, First of all, I am not a comment-person at all. I detest commenting. But I just felt that, in this case, I had to make an exception. At first, I didn't even like your videos, but then I watched this one and a few others which convinced me that you're bloody good (if I may say so). I've just finished the first module of my Front-end development course. I've made all the mistakes that a beginner developer can make, and by the way that you mentioned not to do. I was struggling to put my end assignment together. And I was also binge-watching tutorials on CZcams. However, this was one of the first videos that followed through by actually doing it. So much so that in my end-assignment I almost always used background-blend-mode for my hero images to make the text in the image more readable.

  • @alexandrosdimiropoulos4768

    You are doing great videos, with great explanations that are extremely useful for real life projects. Amazing work.
    My only question regarding this video is this: for how big monitors you must choose an image for?
    If one person has ultrawide 4k screen, should we choose a background image that can stretch and fit to those screens also or we should use media queries with different images for bigger monitors or maybe we should stop and show only a background color after certain dimensions?

  • @isaacsotelo467
    @isaacsotelo467 Před 2 lety

    You drop this...👑 KING

  • @sandaki7134
    @sandaki7134 Před 7 měsíci

    Thank you so much💙. Your video solved my biggest problem.

  • @uchennaonyejeme9221
    @uchennaonyejeme9221 Před rokem

    Thank you very much , now I will understand the functionality

  • @estudiolo
    @estudiolo Před rokem

    This is great, thank you!

  • @kubolavicka6043
    @kubolavicka6043 Před 7 měsíci

    Helped me so much thank you, thumbs up

  • @marshlinejefthas5109
    @marshlinejefthas5109 Před 2 lety

    Hi Kevin thx a million just the video I was looking for very informative and good content.

  • @kyingawa
    @kyingawa Před rokem

    wow. you just solve me problem now. thank you. I like your presentation style.

  • @martnb8219
    @martnb8219 Před rokem

    Great video! Thanks a lot!

  • @chichangchmarak8678
    @chichangchmarak8678 Před 2 lety

    Good suggestions, thanks.

  • @thewise3551
    @thewise3551 Před 2 měsíci

    Cheers dude, Helped!

  • @arg5
    @arg5 Před rokem

    Finally I'm able to resolve the problem regarding background image
    Thank you so much sir 🤩
    🔥🔥🔥🔥🔥✨✨😍🥰

  • @dr__ey
    @dr__ey Před 2 lety

    thank you so much for this Kevin !!!!

  • @anonymous_basics
    @anonymous_basics Před rokem

    very helpful much appreciated .

  • @alejovillores6373
    @alejovillores6373 Před 2 lety

    Thanks! Great video

  • @isaacqadri
    @isaacqadri Před 2 lety +1

    Thanks a lot Kevin ♥️.

  • @FFAs
    @FFAs Před 2 lety +3

    Suggestion that isn't specific to CSS, more general web development for beginners:
    I noticed CZcams is missing a single video or clear series of videos covering the steps/options for setting up a simple contact form for a website from start to finish on both front-end and back-end. Covering basic options like free, cheap, and premium tools for the backend could be an easy extra video topic that would be helpful to beginners.

  • @ZaeemKhaliqAwan
    @ZaeemKhaliqAwan Před 2 lety +1

    There is a multiple background images stacking order thing, by which you can use multiple backgrounds. It is useful for applying for example linear gradient (to control opacity of the background image).

  • @ElementoryMyDearWatson
    @ElementoryMyDearWatson Před měsícem

    So helpful as always. I tried the technique of the background-blend-mode and found that if one adds the alpha channel to the multiply blend mode color (I was using black HSLA ) one can obtain even further control of the 'darkness' buy adjusting the alpha value, i.e. hsl( 0 0 0 / .3); Indebted once again to you sir.

  • @brettlaby4578
    @brettlaby4578 Před 6 měsíci

    there are a lot of talented artists out here, but I have trouble understanding some of them. . Glad-I-found-you {

  • @ruszelsaavedra1647
    @ruszelsaavedra1647 Před rokem

    This is so much helpul for me Sir thank you for your tutorial

  • @aram5642
    @aram5642 Před 2 lety

    King Kevin, in an unlikely case you run out of ideas for a video, I would be curious to see how you approach overflow containers with those nice shadowed transparency masks on the edges when there is overflown content scrolled past the edge. I don't think there is a css-only solution to that, but I know css in your hands can surprise me a lot. Thank you!

  • @jordanislandwebdesign

    Hey, when you say you would rather use firefox over chrome, what do you think of Brave, its built on chrome so its basically the same I dunno about accesiblity though

  • @davidactis7850
    @davidactis7850 Před 9 měsíci

    Awesome video and excellent teaching

  • @RamJairam1
    @RamJairam1 Před 5 měsíci

    Bro Love your teaching so much THANK YOU CHOOOOOOOO Much

  • @gio_adventurelm1578
    @gio_adventurelm1578 Před rokem

    OMG thanks you so muchh! I tried so many time to put a background-image 🤣

  • @plexor-dev
    @plexor-dev Před 2 lety

    Cool, i see that trick background-blend-mode, a few months ago on Twitter.

  • @arthur.poupart2125
    @arthur.poupart2125 Před rokem

    You explain verry well friend!

  • @mrprogo2633
    @mrprogo2633 Před rokem

    this was soooooo useful to me

  • @DilinyerCR
    @DilinyerCR Před 2 lety +1

    Thank you very much!!

  • @josephbecker3023
    @josephbecker3023 Před rokem

    you saved my keyboard from being shattered you beautiful beautiful man

  • @m12652
    @m12652 Před 2 lety

    Great video as usual… Maybe you did one already but how about a video where you combine a background gradient that implies perspective with a foreground drop shadow that scales in proportion to the implied perspective.

  • @sillyways4610
    @sillyways4610 Před 4 měsíci

    good video but i've got one point: my teacher said its not a good idea to place an image via css in the website because for SEO reasons. The search engine won't recognize that there's a picture hence for better SEO it's more advisable to put pictures in or tags since it will be seen as a picture

  • @nucleoinfinito9542
    @nucleoinfinito9542 Před rokem

    I love u, thanks for this video ❤❤

  • @republicofserbia
    @republicofserbia Před rokem

    Kevin, thanks for helping me

  • @user-fo1mq7ox6g
    @user-fo1mq7ox6g Před 26 dny

    Thank you again and again and again and again and again and again and again and again 😊

  • @sumansah00
    @sumansah00 Před 2 lety

    it's such a good and informative video

  • @applesoda77
    @applesoda77 Před rokem

    thank you man fr

  • @sbtoolman12123
    @sbtoolman12123 Před 2 lety +1

    I have tried everything i can find both from this video and off w3c and full stack,i can't get any background images to show, i can get them as regular images, but not background. I know my knowledge is very limited but nothing i have tried works i have tried resizing converting it to another format, copying it..still nothing shows.

  • @domagojhamzic9892
    @domagojhamzic9892 Před rokem

    Thank you, Sir :)

  • @Sanjaya-du1uw
    @Sanjaya-du1uw Před rokem

    thank you so much 👍😊

  • @BadGirl-pn3qu
    @BadGirl-pn3qu Před 7 měsíci

    Thank you so much 🙂

  • @MichaelMullerMWW
    @MichaelMullerMWW Před rokem

    Hi Kevin, is there a simple solution for background images on iPads? Everything I try does not work. The image always appears full-size, pixel for pixel. Any thoughts would be great. Thanks.