A.Jaasma
A.Jaasma

Reputation: 93

Images won't resize in style or in the img itself

I have been stuck with this problem for almost two days already, I am a quite new programmer, and it's probably quite easy to solve.

I have to make a small game with images and words, but the images won't resize. Before they would just resize in <style> however I wanted them, but now they won't even move an inch.

I am sure that the stylesheet is linked correctly because everything else works just fine.

This is my code, can someone figure out how to solve this?
I already looked for answers everywhere but nothing fits the right criteria..

body, html {
  margin-left: 10%;
  margin-right: 10%;
  padding: 0px;
  height: 100%;
  font-family: georgia, "Comic Sans MS";
  background-color: #f0f0f0;
}

header {
  border-bottom: thick solid grey;
}

footer {
    border-top: thick solid grey;
}
.points {
    float: right;
}

.plaatje {
  width: 100px;
  height: 100px;
}
.plaatje2 {
  float: left;
  width: 25%;
}
.igen {
  font-size: 25px;
  font-weight: bold;
}
.sprint {
  float: right;

}
.copyright {
  position: relative;
  bottom: 20px;
  left: 65px;
  font-size: 10px;
}

.img {
  background-color: red;
  width: 25%;
  height: 100px;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Words</title>

    <link rel="stylesheet" href="css/style.css" media="screen" title="no title" charset="utf-8">
    <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
  <script>
  </script>
</head>
<body>

<header>
 <span class="fa fa-refresh" style="font-size:25px;"></span><span class="igen">&nbsp;igen</span>
 <span class="points"><i class="fa fa-thumbs-o-up" style="font-size:24px"></i>Rigtige:  &nbsp;&nbsp;&nbsp; 0 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <i class="fa fa-thumbs-o-down" style="font-size:24px"></i>Forkerte: &nbsp;&nbsp;&nbsp; 0</span>
</header>

<div class="container">
  <div class="img">
    <img src="img/cat.jpg" alt="cat" />
  </div>
  <div class="img">
    <img src="img/beak.jpg" alt="beak" />
  </div>
  <div class="img">
    <img src="img/spoon.jpg" alt="spoon" />
  </div>
  <div class="img">
    <img src="img/milk.jpg" alt="milk" />
  </div>
</div>


<footer>
<img class="dansk" id="dansk" src="img/dansk2.jpg" alt="dansk" />
<img class="sprint" id="sprint" src="img/sprint2.png" alt="sprint" />
<center><span class="copyright"> &copy;2013 laerdansk / FC-Sprint&sup2; Leerbedrijf bronnen </span></center>
</footer>

</body>
</html>

Upvotes: 0

Views: 195

Answers (2)

DebRaj
DebRaj

Reputation: 599

You need to specify the images as img under div class img. So, it should be like:

.img img {
  background-color: red;
  width: 25%;
  height: 100px;
}

But as @foreyez said it's always better practice to give your class a better name so you can distinguish them from the HTML/CSS default parameters such as img

Here is your code: https://jsfiddle.net/debraj/2dyn6vbt/

Upvotes: 1

Shai UI
Shai UI

Reputation: 51978

 <div class="img">
    <img src="img/spoon.jpg" alt="spoon" />
  </div>

is wrong...

it should be:

 <div>
    <img class="img" src="img/spoon.jpg" alt="spoon" />
  </div>

that way your css will target the actual image and give it a size...

.img {
  background-color: red;
  width: 25%;
  height: 100px;
}

Upvotes: 1

Related Questions