Dan*_*nze 23 html css responsive-design css-shapes
响应式CSS圈子:
如果解决方案是javascript,我仍然需要模拟媒体查询触发器.我不需要'媒体查询,但我确实希望能够在特定宽度下控制半径百分比:
@media (max-width : 320px)
{
.x2{padding: 50%;}
}
@media (min-width : 321px) and (max-width : 800px)
{
.x2{padding: 25%;}
}
@media (min-width: 801px)
{
.x2{padding: 12.5%;}
}
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止:
<div class="x1">
<div class="x2">
lol dude
</div>
<div class="x2"></div>
<div class="x2"></div>
<div class="x2"></div>
</div>
.x1
{
float:left;
width:100%;
}
.x2
{
display:block;
float:left;
padding: 12.5%; //Currently being used to control radius.
width:auto;
height:auto;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
-khtml-border-radius: 50%;
background:#eee;
text-align:center;
}
Run Code Online (Sandbox Code Playgroud)
在此解决方案中,将内容添加到圆圈时:
我在这里为此构建了一个可行的解决方案: 响应式CSS圈子
Pra*_*man 14
您不需要对此进行@media查询.这是我的尝试,纯CSS:
.x1 {
overflow:hidden;
}
.x1 .x2 {
display:block;
float:left;
padding: 12.5%;
width:auto;
height:auto;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
-khtml-border-radius: 50%;
background:#eee;
text-align:center;
position: relative;
}
.x1 .x2 span {
position: absolute;
width: 100%;
left: 0;
top: 48%;
line-height: 1em;
height: 1em;
font-size: 100%;
overflow: hidden;
}?
Run Code Online (Sandbox Code Playgroud)
此解决方案可以减少代码大小,但可以保持功能.我已经把原来的.x#,消除了.x0,.x3和.x6那些没有必要的.因此,在最终的解决方案中,您可能会重新编号(但我希望您能看到已消除的内容).
你的任何一块"拆分"需要不同top或left设置的圆圈都需要有一个满足或超过.x2 > div选择器的选择器才能覆盖,因此为什么我有.x2 > .x7一些选择器等.
(如下面的评论中所述,Chrome在启动赏金时OP发布的原始技术存在错误问题.这不能解决这些问题,因此请在另一个浏览器中查看以下内容.)
HTML
<div class="x1">
<div class="x2">
<!-- BEG Content -->
<div class="x4">
dude
</div>
<div class="x7">
dude
</div>
<div class="x8">
dude
</div>
<div class="x5">
dude
</div>
<!-- END Content -->
</div>
<div class="x2"></div>
<div class="x2"></div>
<div class="x2"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.x1 {
margin:0px auto;
}
.x2 {
overflow:hidden;
display:block;
float:left;
width:auto;
height:auto;
position: relative;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
-khtml-border-radius: 50%;
background:#eee;
}
/* BEG Content */
.x2 > div {
position: absolute;
text-align: center;
top: 0;
left: 0;
}
.x4,.x5 {
width:100%;
height: 20%;
}
.x2 > .x7, .x2 > .x8 {
width:50%;
height: 60%;
top: 20%;
}
.x4 {
background-color:blue;
}
.x2 > .x5 {
background-color:yellow;
top: 80%;
}
.x7 {
background-color:green;
}
.x2 > .x8 {
background-color:orange;
left: 50%;
}
/* END Content */
@media (max-width: 320px)
{
.x2 {padding: 50%;}
}
@media (min-width: 321px) and (max-width: 800px)
{
.x2 {padding: 25%;}
}
@media (min-width: 801px)
{
.x1 {width:800px}
.x2 {padding: 12.5%;}
}
Run Code Online (Sandbox Code Playgroud)
编辑:根据评论,看起来OP需要的东西更像是这个小提琴提供的控件(在Chrome中不起作用; OP在编辑时还没有回复我,知道这是否是所需的功能类型).
DIV结构:
我们用overflow:hidden在.x2为漏油关闭背景颜色.x3
的子元素。
注意内容开始于 .x3
<div class="x0">
<div class="x1">
<div class="x2">
<div class="x3">
<!-- BEG Content -->
<div class="x4">
dude
</div>
<div class="x6">
<div class="x7">
dude
</div>
<div class="x8">
dude
</div>
</div>
<div class="x5">
dude
</div>
<!-- END Content -->
</div>
</div>
<div class="x2"></div>
<div class="x2"></div>
<div class="x2"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
@media (max-width: 320px)
{
.x2 {padding: 50%;}
}
@media (min-width: 321px) and (max-width: 800px)
{
.x2 {padding: 25%;}
}
@media (min-width: 801px)
{
.x1 {width:800px}
.x2 {padding: 12.5%;}
}
.x0 {
float:left;
width:100%;
}
.x1 {
margin:0px auto;
}
.x2 {
overflow:hidden;
display:block;
float:left;
width:auto;
height:auto;
position: relative;
border-radius:50%;
-moz-border-radius:50%;
-webkit-border-radius:50%;
-khtml-border-radius: 50%;
background:#eee;
}
.x3 {
position: absolute;
width: 100%;
left: 0;
top:0;
font-size: 100%;
float:left;
height:100%;
background-color:red;
}
/* BEG Content */
.x3 div{float:left;}
.x4,.x5,.x6 {
width:100%;
}
.x7,.x8 {
width:50%;
float:left;
height:100%;
}
.x4,.x5,.x7,.x8 {
text-align:center;
}
.x4 {
background-color:blue;
height:20%;
}
.x5 {
background-color:yellow;
height:20%;
}
.x6 {
height:60%;
}
.x7 {
background-color:green;
}
.x8 {
background-color:orange;
}
/* END Content */
Run Code Online (Sandbox Code Playgroud)
