首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >空div长不了

空div长不了
EN

Stack Overflow用户
提问于 2015-07-05 21:15:36
回答 1查看 45关注 0票数 0

我试图熟悉使用codepen.io的css动画,但我似乎无法使div的大小扩大。似乎有一个简单的解决方案,我只是忽略了。有人能帮忙吗?

代码:http://codepen.io/trebey/pen/PqRZKK

代码语言:javascript
复制
@import 'bourbon';
@import 'neat';

div {
  display: inline-block;
}

.circle-1 {
  max-height: 100px;
  max-width: 100px;
  border: 1px solid #333;
  border-radius: 20%;
  backgrouund: #000;

}

.circle-2 {
  max-height: rem(300);
  max-width: rem(300);
  border: 1px solid #333;
  border-radius: 20%;
  backgrouund: #333;
}

.square-1 {
  max-height: rem(300);
  max-width: rem(300);
  border: 1px solid #333;
  backgrouund: #000;
}

.square-2 {
  max-height: rem(300);
  max-width: rem(300);
  border: 1px solid #333;
  backgrouund: #000;
}
代码语言:javascript
复制
<html>

  <body>
    <div class="square-1"></div>
    <div class="circle-1"></div>
    <div class="circle-2"></div>
    <div class="square-2"></div>
  </body>

</html>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-05 21:23:03

有几个问题。而不是只指定max-width,您应该指定一个width (以及高度)。它是一个内联块元素,根据其内容大小,但是由于没有内容,您应该帮助它。

还有,你拼错了background

最后,rem(300)不起作用。rem (根em)是一个单元,可以像下面为.circle-2所做的那样像empx一样使用,但不能作为函数使用。我想你是从SASS,SCSS或者更少的例子中抄袭的。

代码语言:javascript
复制
@import 'bourbon';
@import 'neat';

div {
  display: inline-block;
}

.circle-1 {
  height: 100px;
  width: 100px;
  border: 1px solid #333;
  border-radius: 20%;
  background: #000;

}

.circle-2 {
  height: 3rem;
  width: 3rem;
  border: 1px solid #333;
  border-radius: 20%;
  background: #333;
}

.square-1 {
  height: rem(300);
  width: rem(300);
  border: 1px solid #333;
  background: #000;
}

.square-2 {
  height: rem(300);
  width: rem(300);
  border: 1px solid #333;
  background: #000;
}
代码语言:javascript
复制
<html>

  <body>
    <div class="square-1"></div>
    <div class="circle-1"></div>
    <div class="circle-2"></div>
    <div class="square-2"></div>
  </body>

</html>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31235066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档