当前位置: 首页 > 编程日记 > 正文

css 形状_在CSS形状之外思考

css 形状

CSS is based off a box model. If you have an image that is a circle that you want to wrap text around, it will wrap around the images’ bounding box.

CSS基于盒模型。 如果您要环绕的图像是一个圆,则它将环绕图像的边界框。

外型 (Shape-outside)

A new CSS property called shape-outside lets you wrap text that conforms to the shape of your image.

一个名为shape-outside的新CSS属性使您可以包装符合图像形状的文本。

什么是外形 (What is shape-outside)

Shape-outside is a new CSS property that changes the shape of items that are wrapped. Instead of being limited to a rectangular bounding box around the image, shape-outside allows us to shape content to fit the image.

Shape-outside是一个新CSS属性,可更改包装物品的形状。 不仅限于图像周围的矩形边界框,还可以通过形状外部使内容的形状适合图像。

Here is how MDN describes shape-outside:

这是MDN描述外部形状的方式:

The shape-outside CSS property uses shape values to define the float area for a float and will cause inline content to wrap around the shape instead of the float’s bounding box.

shape-outside CSS属性使用形状值来定义浮动对象的浮动区域,并将导致内联内容环绕形状而不是浮动对象的边界框。

The most important take away from that description is this new property applies to images that uses a float. The CSS shape-outside property controls how text wraps around any floated image. The text that is wrapped can take the shape of a circle, ellipse, rectangle or polygon.

该描述最重要的一点是,此新属性适用于使用浮点数的图像。 CSS shape-outside属性控制文本如何环绕任何浮动图像。 换行的文本可以采用圆形,椭圆形,矩形或多边形的形状。

使用形状外 (Using shape-outside)

The shape-outside property takes a “basic shape” and applies a shape function to it. The shape function is used to change the shape of the float area of the shape. The CSS shape-outside property provides functionality to create these shape functions:

外部形状属性采用“基本形状”并对其应用形状函数。 形状函数用于更改形状的浮动区域的形状。 CSS shape-outside属性提供创建以下形状函数的功能:

  • circle

  • ellipse

    椭圆
  • polygon

    多边形
  • rectangle

    长方形
  • url

    网址

The image can be positioned with these values. The values are appended to the end:

可以使用这些值来定位图像。 这些值将附加到末尾:

  • margin-box

    边距框
  • padding-box

    填充盒
  • border-box

    边框

The image must have intrinsic dimensions. You must set the height and width of the element. This will be used by the shape function to create a coordinate system that is used when wrapping text around the image.

图像必须具有固有尺寸。 您必须设置元素的高度和宽度。 形状函数将使用它来创建坐标系,该坐标系在将文字环绕图像时使用。

(Circle)

Circle() is one of the functional values provided with shape-outside. The full notation for circle() is circle(r at cx cy) where r is the radius of the circle and cx and cy are the coordinates for the center of the circle. If you omit them, the center of the image will be used as the default values.

Circle()是shape-outside提供的功能值之一。 circle()的完整符号为circle( r在cx cy处) ,其中r是圆的半径,而cx和cy是圆心的坐标。 如果省略它们,则图像的中心将用作默认值。

Here is an example of using shape-outside on a circle:

这是在圆上使用形状外部的示例:

.circle {    height: 200px;    width: 200px;    border-radius: 50%;    background-color: #7db9e8;    margin: 0 25px 5px 0;    float: left;    -webkit-shape-outside: circle();    shape-outside: circle();}

椭圆 (Ellipse)

Ellipse is a variation of the circle where the item is elongated on either the horizontal or vertical axis. The full notation for ellipse() is ellipse(rx ry at cx cy) where rx and ry are the radii for the ellipse and cx and cy are the coordinates for the center of the ellipse.

椭圆是圆的一种变化形式,其中商品在水平或垂直轴上都被拉长。 ellipse()的完整符号为ellipse( 在cx cy处为rx ry ) ,其中rx和ry是椭圆的半径,而cx和cy是椭圆中心的坐标。

Here is an example of using shape-outside on the ellipse:

这是在椭圆上使用形状外部的示例:

.ellipse {    width: 100px;    height: 200px;    border-radius: 50%;    background-color: #7db9e8;    margin: 0 25px 5px 0;    float: left;    -webkit-shape-outside: ellipse(50px 100px at 50% 50%);    shape-outside: ellipse(50px 100px at 50% 50%);}

多边形 (Polygon)

The polygon function provides an unlimited range of shapes. The full notation for polygon() is polygon(x1 y1, x2 y2, …) where each pair specifies the x y coordinates for a vertex of the polygon. To use the polygon() function you must specify a minimum of 3 pairs of vertex.

多边形功能可提供无限范围的形状。 polygon()的完整表示法是polygon(x1 y1,x2 y2,…) 其中每对指定多边形顶点的xy坐标。 要使用polygon()函数,您必须至少指定3对顶点。

Polygon is used with a clip-path. The clip-path CSS property creates a clipping region that defines what part of an element should be displayed. Anything inside the region is displayed, while those outside are hidden.

多边形与剪切路径一起使用。 clip-path CSS属性创建一个裁剪区域,该区域定义应显示元素的哪一部分。 将显示区域内的所有内容,而隐藏外部的内容。

Here is an example of using shape-outside to create two triangle shapes and the text flows between them:

这是一个使用shape-outside创建两个三角形的示例,文本在它们之间流动:

.leftTriangle {    width: 150px;    height: 300px;    background-color: #7db9e8;    margin: 0 25px 5px 0;    float: left;    -webkit-clip-path: polygon(0% 0%, 100% 0%, 50% 100%);    clip-path: polygon(0% 0%, 100% 0%, 50% 100%);    -webkit-shape-outside: polygon(0% 0%, 100% 0%, 50% 100%);    shape-outside: polygon(0% 0%, 100% 0%, 50% 100%);}.rightTriangle {    width: 150px;    height: 300px;    background-color: #7db9e8;    margin: 0 0 5px 25px;    float: right;    -webkit-clip-path: polygon(0% 0%, 100% 0%, 50% 100%);    clip-path: polygon(0% 0%, 100% 0%, 50% 100%);    -webkit-shape-outside: polygon(0% 0%, 100% 0%, 50% 100%);    shape-outside: polygon(0% 0%, 100% 0%, 50% 100%);}

浏览器支持 (Browser Support)

The CSS shape-outside is supported primarily by Chrome, Opera and Safari.

Chrome,Opera和Safari主要支持CSS形状外功能。

获取代码 (Get the Code)

The code for all of the examples can be found in my github repo here.

所有示例的代码都可以在我的github仓库中找到 。

Thanks for reading my article. If you like it, please click on clap icon below so that others will find the article. Here are some more of my articles that you might be interested in:

感谢您阅读我的文章。 如果喜欢,请单击下面的拍手图标,以便其他人可以找到该文章。 以下是您可能感兴趣的其他一些文章:

Here are 5 Layouts That You Can Make With FlexBoxBreadth First Search in JavaScriptInstantiation Patterns in JavaScript

这是您可以使用FlexBox 广度优先搜索的 5种布局 在JavaScript中的 实例化模式

翻译自: https://www.freecodecamp.org/news/mastering-css-series-shape-outside-44d626270b25/

css 形状

相关文章:

js-ES6学习笔记-module(4)

1、<script>标签打开defer或async属性&#xff0c;脚本就会异步加载。渲染引擎遇到这一行命令&#xff0c;就会开始下载外部脚本&#xff0c;但不会等它下载和执行&#xff0c;而是直接执行后面的命令。 defer与async的区别是&#xff1a;前者要等到整个页面正常渲染结束…

图像边缘检测--OpenCV之cvCanny函数

图像边缘检测--OpenCV之cvCanny函数 分类&#xff1a; C/C void cvCanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size3 ); image单通道输入图像.edges单通道存储边缘的输出图像threshold1第一个阈值threshold2第二个阈值aper…

微信小程序 封装网络请求并调用

微信小程序开发交流qq群 526474645 正文&#xff1a; util.js // 网络请求 const request function(url, method, data, msg, succ, fail, com) {// 小程序顶部显示Loadingwx.showNavigationBarLoading();if (msg ! "") {wx.showLoading({title: msg})}wx.requ…

什么是导师负责制_为什么一个导师是不够的

什么是导师负责制by Rick West由里克韦斯特(Rick West) 为什么一个导师是不够的 (Why one mentor just isn’t enough) A mentor can give career guidance and help with learning. They can teach you how to solve problems, network, and the list goes on.导师可以提供职…

CodeForces 114B 【STL应用】

思路&#xff1a; 原来string类能sort 和 swap....太强了.... 注意&#xff1a;字典序最小输出&#xff0c;因为某个地方写挫了&#xff0c;sort了n发&#xff0c;代码挫。 #include <bits/stdc.h> using namespace std; typedef long long LL;int tol; map<string,in…

微信小程序订单页面下拉刷新上拉分页加载

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 正文&#xff1a; 效果图&#xff1a; 代码&#xff1a; json代码&#xff1a; {"enablePullDownRefresh": true,"backgroundColor": "#19ad19" } js代码&#xff1a…

从网络上获取一张图片简单的

告诉ScrollView缩放的视图&#xff0c;要设置scrollView的代理。 转载于:https://www.cnblogs.com/x1024598115/p/4182674.html

es6 generator_让我们探索一下ES6 Generators

es6 generatorby Tiago Lopes Ferreira由Tiago Lopes Ferreira 让我们探索一下ES6 Generators (Let’s explore ES6 Generators) Generators are an implementation of iterables.生成器是可迭代对象的实现 。 The big deal about generators is that they are functions tha…

没听说过这些,就不要说你懂并发了,three。

引言 很久没有跟大家再聊聊并发了&#xff0c;今天LZ闲来无事&#xff0c;跟大家再聊聊并发。由于时间过去的有点久&#xff0c;因此LZ就不按照常理出牌了&#xff0c;只是把自己的理解记录在此&#xff0c;如果各位猿友觉得有所收获&#xff0c;就点个推荐或者留言激励下LZ&am…

设计模式之代理模式(Proxy Pattern)

定义&#xff1a;为其他对象提供一种代理以控制这个对象的访问&#xff0c;也叫做委托模式。 咱们比作游戏&#xff0c;通俗讲代理模式就是&#xff0c;一个主题虚基类派生出两个子类&#xff0c;一个玩家类&#xff0c;实现相关操作&#xff0c;一个是代练类&#xff0c;代替执…

[微信小程序]给data的对象的属性赋值

有问题可以扫码加我微信&#xff0c;有偿解决问题。承接小程序开发。 微信小程序开发交流qq群 173683895 、 526474645 &#xff1b; 正文&#xff1a; <view wx:for"{{leixing}}"><button class"leixing_btn {{user_infor.lx_btnitem.divingtype…

无家可归的iPhone

by Fabrice Dubois通过Fabrice Dubois 无家可归的iPhone (Homeless iPhone) So, apparently the next iPhone won’t have a physical Home button. There’s been much speculation already about what that means for the user. The bottom area of the device, for some, w…

Spring 自动化装配Bean

声明一张cd的接口&#xff1a; public interface CompactDisc {public abstract void play(); } 实现cd接口&#xff1a; Component("SgtPeppers") public class SgtPeppers implements CompactDisc {private String title "Sgt.Peppers Lonely Hearts Club Ba…

js中函数,方法,事件对比区分,什么是方法,什么是函数

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 正文&#xff1a; 简单的理解&#xff1a;函数是运行在本地的&#xff0c;方法是公用的。 事件是开关&#xff0c;通过某某事件触发某个函数 通常命名规范 函数的命名使用小写字母和下划线&#xff…

笔记 JVM调优流程

待续 转载于:https://www.cnblogs.com/leeeee/p/7276287.html

创建新的apple id_Google是新的Apple吗?

创建新的apple idby Sumit Gupta由Sumit Gupta Google是新的Apple吗&#xff1f; (Is Google the new Apple?) 随着众多设备的推出&#xff0c;谷歌试图击败苹果。 “由Google制造”会使Google更像Apple吗&#xff1f; (With the launch of numerous devices, Google is tryi…

yeomen/bower/grunt

yeomen: npm install yo angular-in-action project npm install -g generator-angular npm install -g genrator-webapp yo angular learnangular new angular project yo webapp grunt-by-yeomen package.json npm install (执行package.json所指定的依赖包) bower: npm ins…

Window Server 2008 R2 安装 Share Point 2013

原文地址&#xff1a;http://www.cnblogs.com/jianyus/p/3631905.html转载于:https://www.cnblogs.com/gaobing/p/4191060.html

esp freertos_如何开始使用FreeRTOS和ESP8266

esp freertosby Denis Nuțiu丹尼斯努尤(Denis Nuțiu) 如何开始使用FreeRTOS和ESP8266 (How to get started with FreeRTOS and ESP8266) Recently, I purchased a NodeMCU from AliExpress for about $4. The reason I did this was to find out what all the fuss is about…

[SCOI2007]修车

题目描述 同一时刻有N位车主带着他们的爱车来到了汽车维修中心。维修中心共有M位技术人员&#xff0c;不同的技术人员对不同的车进行维修所用的时间是不同的。现在需要安排这M位技术人员所维修的车及顺序&#xff0c;使得顾客平均等待的时间最小。 说明&#xff1a;顾客的等待时…

[微信小程序]时间戳转日期

有问题可以扫码加我微信&#xff0c;有偿解决问题。承接小程序开发。 微信小程序开发交流qq群 173683895 、 526474645 &#xff1b; 正文&#xff1a; // util.js //时间戳转换成日期时间 function js_date_time(unixtime) {var dateTime new Date(parseInt(unixtime) …

React模式:集中式PropTypes

通过集中化PropType避免重复自己 (Avoid repeating yourself by centralizing PropTypes) There are three popular ways to handle types in React: PropTypes, TypeScript and Flow. This post is about PropTypes, which are currently the most popular.在React中有三种流行…

Java Class SecurityManager

# 前言 简单了解 SecurityManager。具体查阅 API。 # What 它是 Java 沙盒模型控制安全的重要一个环节。它是 Java 的一个类。下面一段话源于SecurityManager API&#xff1a; The security manager is a class that allows applications to implement a security policy. It a…

微信小程序,对象转换成数组

有问题可以扫码加我微信&#xff0c;有偿解决问题。承接小程序开发。 微信小程序开发交流qq群 173683895 、 526474645 &#xff1b; 正文&#xff1a; 对象转数组: var jiu res.data.k4.f3var nArr [];for (var i in jiu){nArr.push(jiu[i]);}console.log(jiu);consol…

sql 事务使用

BEGIN TRAN Tran_Money --开始事务DECLARE tran_error int; SET tran_error 0;BEGIN TRY UPDATE tb_Money SET MyMoney MyMoney - 30 WHERE Name 刘备;SET tran_error tran_error ERROR;--测试出错代码&#xff0c;看看刘备的钱减少&#xff0c;关羽的钱是否会增加--SE…

一群算法_树遍历解释:他们就像一群懒惰的学生,试图欺骗他们的考试

一群算法by Sachin Malhotra由Sachin Malhotra 树遍历解释&#xff1a;他们就像一群懒惰的学生&#xff0c;试图欺骗他们的考试 (Tree Traversals explained: They’re like a class of lazy students trying to cheat on their exam) Imagine that you are enrolled in a mat…

微信小程序转发 分享 打电话功能,完整代码附效果图

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 正文&#xff1a; 按钮绑定在页面内发起转发事件onShareApp:(注意这里是button 并且给他设置了open-type"share" 属性) <button classbottom_1 bottom_1_zf open-type"share" bi…

《DSP using MATLAB》示例 Example 6.25

代码&#xff1a; % x [-0.9, 0.81]; [y, L, B] QCoeff(x, 3) % Unquantized parameters r 0.9; theta pi/3; a1 -2*r*cos(theta); a2 r*r; p1 r*exp(j*theta); p2 p1;% Quantized parameters: N 3; [ahat, L, B] QCoeff([a1, a2], 3); rhat sqrt(ahat(2)); thetah…

sqlserver查询自定义的函数

1)sp_helptext同样适应用自定义函数 2)sys.sql_modules表也可以查 查看函数的源代码: exec sp_helptext 函数名转载于:https://www.cnblogs.com/toSeeMyDream/p/4195030.html

辍学的名人_我辍学去追求成为网络开发人员和设计师的梦想

辍学的名人by Carlos Sz由Carlos Sz 我辍学去追求成为网络开发人员和设计师的梦想 (I dropped out of college to pursue my dreams of being a web developer and designer) When I was 14, I discovered HTML. Thanks to my computer science teacher at school. And from t…