lunes, 6 de septiembre de 2021

CSS Walk 5 Images

 CSS Walk 5 Images


 Let´s use an image in an html file

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS course</title>
    <link rel="stylesheet" type="text/css" href="./css/styles.css" />
  </head>
  <body>
    <img src="./images/css3.png" width="500" alt="imagencss3" />
  </body>
</html>

 
Initialy we define the width of the image in the html file, but we can override this property from the css file
 
img {
  width100px;
}

 
We can deform the image with height and width
 
img {
  width700px;
  height100px;
}

 
 
To maintaing the aspect ratio put one of those parameters as auto.
 
img {
  width700px;
  heightauto;
}
 
Let´s put the image inside a div
 
  <body>
    <div>
      <img src="./images/css3.png" width="500" alt="imagencss3" />
    </div>
  </body>
</html>
 
And assign css properties to see the modifications on the div and img
 
div {
  backgroundrgb(173193250);
  width800;
}

img {
  width300px;
  heightauto;
}
 
Now image is inside a div, and on css we can indicate to use percentage metrics to fill the div
 
div {
  backgroundrgb(173193250);
  width800;
}

img {
  width100%;
  heightauto;
}

 
To center the image inside a container, use margin: auto; and display: block;
 
div {
  backgroundrgb(173193250);
  width100%;
}

img {
  width300px;
  heightauto;
  marginauto;
  displayblock;
}
...

 

 To round the corners use 

img {
  width300px;
  heightauto;
  border-radius20px;
}
 
Let´s try may variants of the css capabilities on images
 
 <body>
    <div>
      <img src="./images/css3.png" width="500" alt="imagencss3" />
      <img
        class="class-a"
        src="./images/css3.png"
        width="500"
        alt="imagencss3"
      />
      <img
        class="class-b"
        src="./images/css3.png"
        width="500"
        alt="imagencss3"
      />
      <img
        class="class-c"
        src="./images/css3.png"
        width="500"
        alt="imagencss3"
      />
      <img
        class="class-d"
        src="./images/css3.png"
        width="500"
        alt="imagencss3"
      />
      <img
        class="class-scuare"
        src="./images/css3.png"
        width="500"
        alt="imagencss3"
      />
      <img
        class="class-circled"
        src="./images/css3.png"
        width="500"
        alt="imagencss3"
      />
    </div>
  </body>
 
...
div {
  width100%;
}

img {
  width300px;
  heightauto;
  border-radius20px;
}

.class-a {
  border-radius30px;
}

.class-b {
  border-radius30%;
}

.class-c {
  border-radius50px;
}

.class-d {
  border-radius50%;
}

.class-scuare {
  width300px;
  height300px;
}

.class-circled {
  width300px;
  height300px;
  border-radius50%;
}

 

 
Setting box-shadow to each img
 
img {
  width300px;
  heightauto;
  border-radius20px;
  box-shadow10px 10px 5px #aaa;
  margin10px;
}

.class-a {
  border-radius30px;
  box-shadow10px 10px 5px #aaa;
  margin10px;
}

.class-b {
  border-radius30%;
  box-shadow10px 10px 5px #aaa;
  margin10px;
}

.class-c {
  border-radius50px;
  box-shadow10px 10px 5px #aaa;
  margin10px;
}

.class-d {
  border-radius50%;
  box-shadow10px 10px 5px #aaa;
  margin10px;
}

.class-scuare {
  width250px;
  height250px;
  box-shadow10px 10px 5px #aaa;
  margin10px;
}

.class-circled {
  width300px;
  height300px;
  border-radius50%;
  box-shadow10px 10px 5px #aaa;
  margin10px;
}

 
...

 Simplifying css code and adding padding and border
img {
  width300px;
  heightauto;
  border-radius20px;
  box-shadow10px 10px 5px #aaa;
  margin10px;
  padding10px;
  border2px solid darkgray;
}

.class-a {
  border-radius30px;
}

.class-b {
  border-radius30%;
}

.class-c {
  border-radius50px;
}

.class-d {
  border-radius50%;
}

.class-scuare {
  width250px;
  height250px;
}

.class-circled {
  width300px;
  height300px;
  border-radius50%;
}
 
...

 
eot

No hay comentarios:

Publicar un comentario