首页 > 其他分享 >css45 CSS Math Functions

css45 CSS Math Functions

时间:2024-06-01 18:00:15浏览次数:17  
标签:Functions min max value width Math css45 calc div1

https://www.w3schools.com/css/css_math_functions.asp

 

The CSS math functions allow mathematical expressions to be used as property values. Here, we will explain the calc(), max() and min() functions.


The calc() Function

The calc() function performs a calculation to be used as the property value.

CSS Syntax

calc(expression)
ValueDescription
expression Required. A mathematical expression. The result will be used as the value.
The following operators can be used: + - * /

Let us look at an example:

Example

Use calc() to calculate the width of a <div> element:

#div1 {
  position: absolute;
  left: 50px;
  width: calc(100% - 100px);
  border: 1px solid black;
  background-color: yellow;
  padding: 5px;
}
<!DOCTYPE html>
<html>
<head>
<style>
#div1 {
  position: absolute;
  left: 50px;
  width: calc(100% - 100px);
  border: 1px solid black;
  background-color: yellow;
  padding: 5px;
}
</style>
</head>
<body>

<h1>The calc() Function</h1>

<p>Create a div that stretches across the window, with a 50px gap between both sides of the div and the edges of the window:</p>

<div id="div1">Some text...</div>

</body>
</html>

 



The max() Function

The max() function uses the largest value, from a comma-separated list of values, as the property value.

CSS Syntax

max(value1, value2, ...)
ValueDescription
value1, value2, ... Required. A list of comma-separated values - where the largest value is chosen

Let us look at an example:

Example

Use max() to set the width of #div1 to whichever value is largest, 50% or 300px:

#div1 {
  background-color: yellow;
  height: 100px;
  width: max(50%, 300px);
}
<!DOCTYPE html>
<html>
<head>
<style>
#div1 {
  background-color: yellow;
  height: 100px;
  width: max(50%, 300px);
}
</style>
</head>
<body>

<h1>The max() Function</h1>

<p>Use max() to set the width of #div1 to whichever value is largest, 50% or 300px:</p>

<div id="div1">Some text...</div>

<p>Resize the browser window to see the effect.</p>

</body>
</html>

 

 

The min() Function

The min() function uses the smallest value, from a comma-separated list of values, as the property value.

CSS Syntax

min(value1, value2, ...)
ValueDescription
value1, value2, ... Required. A list of comma-separated values - where the smallest value is chosen

Let us look at an example:

Example

Use min() to set the width of #div1 to whichever value is smallest, 50% or 300px:

#div1 {
  background-color: yellow;
  height: 100px;
  width: min(50%, 300px);
}
<!DOCTYPE html>
<html>
<head>
<style>
#div1 {
  background-color: yellow;
  height: 100px;
  width: min(50%, 300px);
}
</style>
</head>
<body>

<h1>The min() Function</h1>

<p>Use min() to set the width of #div1 to whichever value is smallest, 50% or 300px:</p>

<div id="div1">Some text...</div>

<p>Resize the browser window to see the effect.</p>

</body>
</html>

 


All CSS Math Functions

FunctionDescription
calc() Allows you to perform calculations to determine CSS property values
max() Uses the largest value, from a comma-separated list of values, as the property value
min() Uses the smallest value, from a comma-separated list of values, as the property value

标签:Functions,min,max,value,width,Math,css45,calc,div1
From: https://www.cnblogs.com/emanlee/p/18226225

相关文章

  • [JS零碎知识点01]Math内置对象
    一:Math数学对象Math 是一个内置对象,它拥有一些数学常数属性和数学函数方法。二:random()方法1 random()简介Math.random()为随机数函数,返回一个0到1之间随机小数数,并且包括0不包括1,[0,1)2随机数生成算法(1)生成0-10之间的随机整数Math.floor(Math.random()*11)推倒:Math......
  • PySpark Functions
    1.SelectColumns-Example`df=df.select( "customer_id", "customer_name")`2.CreatingorReplacingacolumn-Exampledf=df.withColumn("always_one",F.lit(1))df=df.withColumn("customer_id_copy",F.col(......
  • 【Python快速上手(三十四)】- Python math 模块
    目录Python快速上手(三十四)-Pythonmath模块Pythonmath模块详解1.导入math模块2.基本数学运算3.三角函数4.双曲函数5.特殊函数6.浮点运算辅助函数7.常量8.实际应用案例9.小结Python快速上手(三十四)-Pythonmath模块Pythonmath模块详解math模块......
  • Mathematics
    数学,西文叫\(\mathbf{mathematics}\),来自希腊语,它的意思是聪明人,聪明的,聪明人干的事。如果一个人什么都会的话,我们就叫他\(\mathbf{polymath}\)(博学家)。数学的描述对象:数、形、形式、集合等。物理学正确与否的问题,一定是通过通过现实世界的观察,只有被观察到了,或者被验证了的时......
  • 最新版本MathType的优势
    一份订阅,多平台可用只需订阅一次,即可在Windows、macOS、LMS平台或任何其他桌面或基于Web的环境上使用MathType。安全和GDPR合规性严格遵守所有最新的安全和GDPR标准,保护您的计算机免受风险。无忧迁移顺畅无忧地保留工作内容,并像使用旧版本MathType一样继......
  • Math Record
    T1.P3327知识点:莫比乌斯反演,数论分块我们知道\(d(ij)=\sum_{x|i}\sum_{y|j}[\gcd(x,y)==1]\)。所以我们就要求\(\sum^n_{i=1}\sum^m_{j=1}\sum_{x|i}\sum_{y|j}[\gcd(x,y)==1]\)。即为\(\sum^n_{i=1}\sum^m_{j=1}\lfloor\dfrac{n}{i}\rfloor\time......
  • MathType免费安装公众号mathtype30天到期后怎么激活
     MathType2024:数学公式编辑的革新者随着科研和教育的不断进步,对数学公式编辑软件的需求日益增加。在这个数字化时代,一款功能强大、操作简便的专业数学公式编辑器显得尤为重要。今天,我们要介绍的就是备受瞩目的新型工具——MathType2024,这是一款旨在满足科研人员、教师和学生......
  • MathType7.5.9中文安装包破解激活图文详细教程
     MathType2024是一款最新发布的专业数学公式编辑软件,它以其卓越的功能和强大的性能在业界引起了广泛关注。这款软件不仅能够帮助用户轻松地创建和编辑复杂的数学公式,还能够与各种流行的文档处理软件无缝集成,极大地提高了用户的工作效率和准确性。让我们来看一下MathType2024......
  • mathtype7最新产品密钥2024免费激活码
     MathType2024,作为最新的专业数学公式编辑神器,以其强大的功能和用户友好的界面,正在重新定义我们编写和分享复杂数学公式的方式。我们需要了解什么是MathType。MathType是一款专业的数学公式编辑软件,它可以帮助教师、学生和科研人员快速创建复杂的数学公式,并可以轻松插入到各......
  • Semantic Kernel入门系列:利用Handlebars创建Prompts functions
    引言本章我们将学习通过HandlebarsPromptsTemplate来创建Promptsfunctions。什么是Handlebars?Handlebars是一个流行的JavaScript模板引擎,它允许你通过在HTML中使用简单的占位符来创建动态的HTML。它使用模板和输入对象来生成HTML或其他文本格式。Handlebars模板看......