How css sets the picture to be as wide as the container
This article mainly shows you "css how to set the picture to be as wide as the container", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn "css how to set the picture to be as wide as the container".
In css, you can use the width attribute to set the picture element to be as wide as the container, which is used to set the width of the element. When the attribute value is "100%", the width of the element is the width of the parent element, that is, the width of the container, and the syntax is "picture element {width:100%;}".
The operating environment of this tutorial: windows7 system, CSS3&&HTML5 version, Dell G3 computer.
How does css set the picture to be as wide as the container
In css, we only need to use the width property of the image to set the image to be as wide as the container, and we only need to set the width property value of the image to 100%.
The width property sets the width of the element. Defines a percentage width based on the width of the containing block (parent element) when the attribute value unit is%. That is, the percentage width of the container
Examples are as follows:
Document div {width: 200px; height: 200px; border:1px solid # 000000;} div img {width: 100%;}
Output result:
Similarly, if you want the height to be as high as the container, you just need to add the height attribute and set the property value to 100%.
The above is all the content of the article "how css sets the picture to be as wide as a container". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!