首页 > 其他分享 >css实现:不固定宽高,随内容宽度自动增长的圆形

css实现:不固定宽高,随内容宽度自动增长的圆形

时间:2023-12-01 10:12:35浏览次数:39  
标签:align 宽高 height 宽度 inline circle display css

css代码:

    .circle {
      display: inline-block;
      border-radius: 50%;
      min-width: 20px;
      min-height: 20px;
      padding: 5px;
      background: red;
      color: white;
      text-align: center;
      line-height: 1;
      box-sizing: content-box;
      white-space: nowrap;
    }
    .circle::before {
      content: "";
      display: inline-block;
      vertical-align: middle;
      padding-top: 100%;
      height: 0;
    }
    .circle span {
      display: inline-block;
      vertical-align: middle;
    }

html代码

<div class="circle"><span>8</span></div>
<div class="circle"><span>64</span></div>
<div class="circle"><span>512</span></div>
<div class="circle"><span>4096</span></div>
<div class="circle"><span>9999999999</span></div>

参考网址:html - CSS circle without using fixed width and height - Stack Overflow 

 

标签:align,宽高,height,宽度,inline,circle,display,css
From: https://www.cnblogs.com/hyt09/p/17869105.html

相关文章

  • CSS设置margin-top失效及解决办法
    在web网站开发中,有时候我们给html元素设置的margin-top或margin-bottom属性,但是无效,并没有取到任何作用,这是什么原因呢?常出现两种情况:1、兄弟元素之间margin-top失效先看下面代码:<div><divclass="box1">float:left</div><divclass="box2">clear:both;margin-top:20......
  • CSS-transparent--透明属性 用transparent写一个三角形
    csstransparent是一种全透明属性。当用在一个元素覆盖另一个元素时,想显示下面的元素,就用到了transparent属性。代码:div{width:0;height:0;/*边框底部*/border-bottom:100pxsolidblack;/*边框左部*/border-left:50pxsolidtranspare......
  • CSS进阶1--字体样式-文本样式
    link.css--连接外部样式表1.文字样式:①font-family:字体样式②font-style:文本的字体样式 属性:normal-正常 italic-斜体字样式显示 oblique-文字向一边倾斜(与italic类似,但不太支持)③font-variant--以小型大写字体或正......
  • CSS-background 背景图片
    更多CSS进阶: https://www.cnblogs.com/warmNest-llb/p/17866954.html 1.背景介绍元素的背景属性:background简写属性,作用是将背景属性设置在一个声明中。background-attachment:背景图像是否固定或者随着页面的其余部分滚动。scroll默认值。/fixed当......
  • CSS
    1、文字超出用省略号...鼠标悬停显示全部文字<divstyle="font-size:12px;margin-top:30px;padding:10px20px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4;hei......
  • css三角形
    https://blog.csdn.net/weixin_43951592/article/details/127442235https://blog.csdn.net/m0_60237095/article/details/130076471 ......
  • vue+iframe 添加请求头,自适应宽度和高度,iframe将token放在请求头不是src的url中
    1<template>2<divclass="iframe">3<iframe4v-if="isRequestHeader"5id="myIframe"6name="myIframe"7src=""8frameborder="0&qu......
  • 每日一练:css关键词:inherit、initial、revert、unset解释
    1、inherit(继承)inherit关键词用于将一个属性值设置为其父元素的相同属性值。它是一种实现样式继承的方式,使子元素继承父元素的样式属性。如果父元素没有明确定义该属性,子元素将继承到该属性的默认值。这个关键词通常用于处理文本属性,如文本颜色、字体等。<div><p>这是......
  • Why I see scss file in my chrome inspector?
    WhyIseescssfileinmychromeinspector?BecausetherearemapfilesinyourCSSfolderlike*.css.mapand*.scss.map.Itbasicallyreversemapstheglobal.csswhichisbeingusedbythebrowsertotheconstituent.scssfiles.Theyaretherebecause......
  • 关于CSS3的学习
    CSS的普通选择器:标签选择器、id选择器、类选择器、通用选择器(*)、分组选择器(将具有相同样式的元素放在一起,之间用","分隔)。注:类名和id名不能以数字开头。 rgba是rgb颜色的扩展,前三个值为三原色和rgb一致,第四个值是设置透明度的,1为完全不透明,0是完全透明为白色。hex颜色是用......