响应中心内容的圈子 [英] Responsive circle with centered content

查看:239
本文介绍了响应中心内容的圈子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法做到以下几点:

Is there a way to make the following:

#id {
  border-radius: 100px;
  width: 100px;
  height: 100px;
}

<div id="circle">
  <h3>Hello</h3>
</div>

div ,文字垂直和水平居中。同时保持圈子响应。

我的意思是说宽度 50% div 的$ c>,同时保持 height 百分比等于制作一个圆圈。

A round div with the text centered vertically and horizontally. At the same time keeping the circle responsive.
By that I mean having a width of say 50% of the containing div, at the same time keeping the height percentage equal as to make a circle.

将静态 100px 更改为pertentages会使圆圈呈椭圆形。

And changing the static 100px to pertentages makes the circle oval.

推荐答案

视口单元



如果使用相同的视口单元( vw vh )然后你应该得到一个响应圈。

Viewport Units

If you use the same viewport unit (either vw or vh) then you should get a responsive circle.

<$>的视口单位c $ c> 100 将是宽度或高度的100%。因此它与使用百分比非常相似。

A viewport unit of 100 would be 100% of either the width or height. Therefore it is very similar to using a percentage.

div {
  width: 10vw;
  height: 10vw;
  border-radius: 50%;
  background: blue;
}

<div></div>

这篇关于响应中心内容的圈子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆