This article will introduce you to CSS3’s adaptive layout that can be calculated—calc(). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
To start, we need to understand what calc() is. calc() is a CSS function. You can use calc() to set the margin, padding, width and other attributes of the element.
And you You can also nest another calc() inside a
calc(). The syntax of
clac() is very simple. Use mathematical expressions to express:
expression is a mathematical expression used to calculate the length. The result of this expression will be used as the final value.
clac() uses the four arithmetic operations of " ", "-", "*" and "/". It can use units such as percentage, px, em, rem, etc., and can mix multiple units for calculation
It should be noted that
If "0" is used as the divisor, the HTML parser will throw an exception.
When " " and "-" are used, there must be spaces before and after such as calc(100 %-15px) This is wrong
When "*" and "/" are used, there is no need to leave spaces before and after, but it is recommended to add spaces
Give two examples
1 nbsp;html> 2 3 4 <meta> 5 <title>demo</title> 6 <style> 7 .box{ 8 width: 500px; 9 height: 300px; 10 } 11 .left{ 12 width: 250px; 13 background:#ccc; 14 float: left; 15 } 16 .right{ 17 width: calc(100% - 250px); 18 float: right; 19 background: #333; 20 } 21 .left,.right{ 22 height: 100%; 23 } 24 </style> 25 26 27 28 <p> 29 </p><p></p> 30 <p></p> 31 32 33 34
1 nbsp;html> 2 3 4 <meta> 5 <title>demo</title> 6 <style> 7 .demo{ 8 width: 500px; 9 } 10 .box{ 11 width: 100%; 12 height: 30px; 13 background: #ccc; 14 } 15 input{ 16 width: 100%; 17 border:1px solid #333; 18 width: calc(100% - (0px + 1px) * 2); 19 } 20 </style> 21 22 23 <p> 24 </p><p> 25 <input> 26 </p> 27 28 29
If you don’t use calc()
The compatibility problem is not big either
The above is the entire content of this article. For more related tutorials, please visit CSS Basics Video Tutorial, CSS3 video tutorial, bootstrap video tutorial!
The above is the detailed content of css3 implements adaptive layout that can be calculated—calc(). For more information, please follow other related articles on the PHP Chinese website!

React响应式设计指南:如何实现自适应的前端布局效果随着移动设备的普及和用户对多屏幕体验的需求增加,响应式设计成为了现代前端开发的重要考量之一。而React作为目前最流行的前端框架之一,提供了丰富的工具和组件,能够帮助开发人员实现自适应的布局效果。本文将分享一些关于使用React实现响应式设计的指南和技巧,并提供具体的代码示例供参考。使用React的Fle

两种方法:1、利用display属性,只需给元素添加“display:none;”样式即可。2、利用position和top属性设置元素绝对定位来隐藏元素,只需给元素添加“position:absolute;top:-9999px;”样式。

实现方法:1、使用“:active”选择器选中鼠标点击图片的状态;2、使用transform属性和scale()函数实现图片放大效果,语法“img:active {transform: scale(x轴放大倍数,y轴放大倍数);}”。

css3中的动画效果有变形;可以利用“animation:动画属性 @keyframes ..{..{transform:变形属性}}”实现变形动画效果,animation属性用于设置动画样式,transform属性用于设置变形样式。

在css3中,可以利用“animation-timing-function”属性设置动画旋转速度,该属性用于指定动画将如何完成一个周期,设置动画的速度曲线,语法为“元素{animation-timing-function:速度属性值;}”。

HTML教程:如何使用Flexbox进行自适应等高等宽等间距布局,需要具体代码示例引言:在现代网页设计中,布局是一个非常关键的因素。对于需要展示大量内容的页面来说,如何合理地安排元素的位置和大小,以实现良好的可视性和易用性,是一个重要的问题。Flexbox(弹性盒布局)就是一个非常强大的工具,通过它可以轻松实现各种灵活的布局需求。本文将详细介绍Flexbox

css3线性渐变可以实现三角形;只需创建一个45度的线性渐变,设置渐变色为两种固定颜色,一个是三角形的颜色,另一个为透明色即可,语法“linear-gradient(45deg,颜色值,颜色值 50%,透明色 50%,透明色 100%)”。

实现方法:1、利用“元素{animation:名称 时间}”语句给元素绑定动画,并设置动画所需的时间;2、利用“@keyframes 名称{100%{height:渐变高度值;}}”语句,设置高度改变的动画动作,实现渐变效果即可。


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

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

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
