Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

怎样把一个圆做成响应式呢?怎样动态设置高度?

我设置了最小宽度和高度。但是每个人的电脑屏幕宽度不同。所以无法知道宽度是多少?高度也无法设置。如果拉伸之后。就变成扁的了。怎么解决这个问题呢?我用的scss能不能计算宽度呢?然后把宽度赋值给高度。变成一样的宽高、
如图:
image.png
image.png
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
/* 外层保尺寸 */
.circle-wrapper{
    position: relative
}
/* 中间画圆 */
.circle-wrapper>.circle{
    padding-bottom: 100%;
    border-radius: 50%;
    position: relative;
    border: solid 1px;
    width: 100%;
    height: 0;
}
/* 内层填内容 */
.circle-wrapper>.circle>.inner{
    position: absolute;
    width: 100%;
    bottom: 0;
    left: 0;
    top: 0;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...