1. Web page production skills example solution: Use CSS to control the adaptive size of images
Automatically adapt to the size of images is a very common function, when making In order to prevent the image from opening the container, we need to control the size of the image. Can we use CSS to control the image so that it adapts to the size?
We have thought of a relatively simple solution. Although it is not perfect, if your requirements are not very high, it can already meet your needs. Let’s look at the following code:
p img { max-width:600px; width:600px; width:expression(document.body.clientWidth>600?"600px":"auto"); overflow:hidden; }
◎ max-width:600px; The maximum width is 600px under IE7, FF and other non-IE browsers. But it doesn't work in IE6.
◎ width:600px; The size of the image is 600px in all browsers;
◎ When the image size is larger than 600px, it will be automatically reduced to 600px. Valid in IE6.
◎ overflow:hidden; Hide the excess part to avoid stretching and deformation caused by failure to control the image size.
#2. Sometimes the picture is too large, which will destroy the neat layout of the web page. At this time, you can use css to force the height or width of the image to be compressed proportionally
The css code is as follows:
img,a img{ border:0; margin:0; padding:0; max-width:590px; width:expression(this.width>590?"590px":this.width); max-height:590px; height:expression(this.height>590?"590px":this.height); }
In this way, if the height or width of the image exceeds 590px, it will be proportional Compress to 590px. If it does not exceed, it will be displayed at the original size.
The above is the detailed content of Introduction to how to control image size in CSS. For more information, please follow other related articles on the PHP Chinese website!

For a while, iTunes was the big dog in podcasting, so if you linked "Subscribe to Podcast" to like:

We lost Opera when they went Chrome in 2013. Same deal with Edge when it also went Chrome earlier this year. Mike Taylor called these changes a "Decreasingly

From trashy clickbait sites to the most august of publications, share buttons have long been ubiquitous across the web. And yet it is arguable that these

In this week's roundup, Apple gets into web components, how Instagram is insta-loading scripts, and some food for thought for self-hosting critical resources.

When I was looking through the documentation of git commands, I noticed that many of them had an option for . I initially thought that this was just a

Sounds kind of like a hard problem doesn't it? We often don't have product shots in thousands of colors, such that we can flip out the with . Nor do we

I like when websites have a dark mode option. Dark mode makes web pages easier for me to read and helps my eyes feel more relaxed. Many websites, including

This is me looking at the HTML element for the first time. I've been aware of it for a while, but haven't taken it for a spin yet. It has some pretty cool and


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor