Max-width, maximum element width in CSS
Width and max properties: width defines the width of the element.
As mentioned earlier, the block element always takes up the full width (pull from the left to the right).Setting the width by the width property for the block element will prevent it from stretching to the outer edge.You can then set the margin automatically, centering the element horizontally.The element will only occupy the predefined width, the rest will be divided equally for the two margins.
Note: When the window width is smaller than the element, the browser adds a horizontal scroll bar to the page.In this case, max-width should be used.This just makes the browser easier to handle when the window is too small, which is also important on small screen devices.
Here is an example of how to use the above two width and max-width features.
div.ex1 {
width : 500px ;
margin : auto ;
border : 3px solid #73AD21 ;
}
div.ex2 {
max-width : 500px ;
margin : auto ;
border : 3px solid #73AD21 ;
}
Change the browser window width to see the difference
Previous lesson: Display element in CSS
The following article: Location of elements in CSS
You should read it
May be interested
- CSS Selector in jQuerythe jquery library supports almost all selector in cascading style sheet (css), when mentioned on the world wide web consortium.
- Corpse pose helps sleep well and regenerate energylie down and relax in the 'corpse' position - legs shoulder-width apart, arms along the body, bringing maximum relaxation to the body, helping you sleep well.
- Change the width of columns and the height of rows in Excelthe default column widths and row heights in excel may not match the data you enter. you want to change the width, height of rows and columns so that data is displayed fully on cells in excel.
- What factors determine the strength of a CPU?there are 7 main factors that directly affect the processing power of the cpu. these factors include: number of cores, clock speed, hyper-threading, cache, word size, address bus width, data bus width.
- Open Inspect Element and View Source on Microsoft Edge browserif you are a developer, you may have to use the site's source code. and you may also have to use the inspect element tool to find a specific code and design of a website. if you are using the microsoft edge browser, the view source and inspect element options are disabled by default.
- How to adjust text spacing on PowerPoint - Keep the text width the samewhen changing the stretch or elastic distance between letters in a powerpoint slide, the width of the letters is not changed accordingly.
- How to adjust word spacing on PowerPointwhen changing the stretch or elastic distance between words in a powerpoint slide, the width of the text is not changed.
- Canvas element in HTML5the element is used to draw simple word graphic elements such as lines to complex graphics (lines, boxes, circles, lettering, image insertion ...). however, one thing in particular is that its content is built from javascript.
- Google+ changes the way links are displayed, similar to Facebooknow when you share a link on a google+ social network you will see a small but useful change. the image displayed in the link has a larger frame, maximum width and bottom, including the title, path, and short description.
- How to change the Maximum processor frequency setting in Windows 10processor frequency specifies the operating frequency of the core (s) in the cpu, in mhz. the higher the cpu frequency, the faster the processor. this guide will show you how to change the maximum processor frequency setting in windows 10.