Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

image size not changing

hey guys.

I'm making an website and the image size isn't changing i've tired all sorts of ways but it's weird.

HTML CODE

<div class="main-content"> <!-- <center><img class="bodybg"src="img/body.png"></center> -->

<div class="sides-show">
    <img class="test" src="lols.png">


</div>

CSS CODE

.main-content {

background: url("../img/body.png") no-repeat; background-size: 70% 70%; }

.slide-show { width: 70%; height: 100px; border: 2px solid white; }

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

We're going to need to see all your code including your file/directory structure to even confirm that your CSS is being loaded properly. Can you post us a link to either a workspace or your codepen?

I can say this so far: you're using the center tag which is deprecated. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center

Also you referenced classes called test, bodybg and sides-show, which is nowhere in the CSS you've posted. In your CSS you have a slide-show class which is found nowhere in your html.

Steven Parker
Steven Parker
243,656 Points

Jennifer I was partly joking .. maybe you overlooked the smiley?

Anway, it was, and is, good advice. Put it back in as an "FYI".

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Steven Parker Sorry. I had a moment there :) Ever have one of those days where everything you do is wrong somehow? I'm having one today :P

2 Answers

Steven Parker
Steven Parker
243,656 Points

You say the size "isn't changing". But when should it change?

Do you mean when you resize the window? One way to make that happen is to give the element a size based on a percentage, or on viewport units. Without that kind of specification, the size would not change with the window.

To enable specific analysis of your issue, consider creating a Treehouse Workspace for it. You can then use the snapshot function in the workspace and provide the link to it here.

https://w.trhou.se/dkke0lkqkh

i'm trying to to make the "body.png" image to be 70% wide and 1000px high. so i can put content into the "body.png" like over the picture

The img test, isn't there for any reason

https://w.trhou.se/dkke0lkqkh

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

First, you're missing an ending div tag before the closing of the body. But my primary concern here is why you even need the body.png. When I preview that picture in the forked workspace it appears as a black square. That's doable with CSS without having to load in an extra resource. Also the link to your background picture is incorrect. It should be:

 background: url("../body.png") no-repeat;