【问题标题】:Is it a material design bug for web它是网页的材料设计错误吗
【发布时间】:2019-06-23 16:12:27
【问题描述】:

插入背景 (svg) 后,我的 mdc 卡右侧有空白区域。 示例在 codepen https://codepen.io/BhavyaSingh2003/pen/ZwByBy

body,
html {
  height: 100%;
}

.mycard {
  height: 90%;
  width: 90%;
  margin-right: 5%;
  margin-left: 5%;
  background-image: url("https://svgshare.com/i/Aut.svg");
  background-position: center;
  background-size: 100% auto;
  background-repeat: no-repeat;
}
<script src="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.js"></script>
<link href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css" rel="stylesheet"/>


<link rel='stylesheet' href='https://fonts.googleapis.com/icon?family=Material+Icons'>
<div class="mdc-card mycard">
</div>

请告诉我如何解决这个问题,因为我必须设计一个带有背景的注册表单,我不能放置这样的图像,因为我已经在上面放置了文本字段和其他东西,所以它必须在背景中。

【问题讨论】:

  • 你也需要重新设置边距:codepen.io/anon/pen/JxbrVM
  • 我已经做到了
  • 但仍有空白
  • 你需要阴影吗?
  • 你没有在 body 上重新设置边距...,但你是在谈论图像比例吗?

标签: html css material-design


【解决方案1】:

如果您愿意,可以添加此自定义解决方案。但这不是完美的解决方案。

body,html{
  height:100%;
margin:0px;
}
.mycard {
  height: 90%;
  width: 90%;
}


.mdc-card.mycard:before {
    content: '';
    position: absolute;
    height: 100%;
    width: 100%;
    background-image: url(https://svgshare.com/i/Aut.svg);
    background-repeat: no-repeat;
    background-size: 100%;
    right: -20%;
    top: 0;
    background-position: right;
    white-space: unset;
}

【讨论】:

  • "" 后台网址链接
  • 运气不好再次访问我分享的codepen url,看到仍然有空白
  • 问题现在已经解决,这是因为矩形元素在 svg 中倾斜
猜你喜欢
  • 2019-01-29
  • 1970-01-01
  • 2015-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-19
  • 1970-01-01
  • 2015-02-05
相关资源
最近更新 更多