- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在将我的 SVG 与圆心对齐时遇到问题,我应该怎么做?
我试过使用 imgs 代替 svgs,但质量大打折扣。此外,我已经尝试过堆栈溢出的答案并尝试使用这些解决方案但无济于事。
HTML
<div class="topics-container">
<div class="row1">
<div class="topic">
<div class="icon-cybersecurity"><svg>BLAHBLAHBLAH</svg></div>
<div class="topic-name">Cybersecurity and Social Engineering</div>
</div>
<div class="topic">
<div class="icon-vr"><svg>BLAHBLAHBLAH</svg></div>
<div class="topic-name">Virtual Reality</div>
</div>
.
.
.
</div>
<div class="row2">
<div class="topic">
.
.
.
</div>
.
.
.
</div>
</div>
SASS:
.row1
background: blue
+display(flex)
+align-items(center)
.row2
background: red
+display(flex)
+align-items(center)
.topic
display: block
margin: auto
[class^="icon-"]
+size(100px)
background: green
border-radius: 50%
最佳答案
感谢您的帮助,我找到了一个解决方案,svg 文件没有与中心对齐,所以我不得不在 illustrator 中这样做。
步骤如下:
我使用的代码:萨斯:
.row1
+display(flex)
+align-items(center)
.row2
padding-top: 150px
+display(flex)
+align-items(center)
padding-bottom: 100px
.topic
display: block
margin: auto
background: white
[class^="icon-"]
+size(150px)
border-radius: 50%
.topic-name
font-size: 20px
font-style: bold
text-align: center
HTML:(与问题相同)
<div class="topics-container">
<div class="row1">
<div class="topic">
<div class="icon-cybersecurity"><svg>BLAHBLAHBLAH</svg></div>
<div class="topic-name">Cybersecurity and Social Engineering</div>
</div>
<div class="topic">
<div class="icon-vr"><svg>BLAHBLAHBLAH</svg></div>
<div class="topic-name">Virtual Reality</div>
</div>
.
.
.
</div>
<div class="row2">
<div class="topic">
.
.
.
</div>
.
.
.
</div>
</div>
我的 SVG 文件:
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.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10.6,4.4-15c1.3-2.2,2.7-4.1,4-5.4C36.8,45,38.1,44.4,39,44.4z M62,51.5c-1.1,0-2,0.9-2,2
s0.9,2,2,2s2-0.9,2-2S63.1,51.5,62,51.5z M37,52.6v3.1h-3v3.1h3v3.1h3v-3.1h3v-3.1h-3v-3.1H37z M58,55.6c-1.1,0-2,0.9-2,2s0.9,2,2,2
s2-0.9,2-2S59.1,55.6,58,55.6z M66,55.6c-1.1,0-2,0.9-2,2s0.9,2,2,2s2-0.9,2-2S67.1,55.6,66,55.6z M62,59.7c-1.1,0-2,0.9-2,2
c0,1.1,0.9,2,2,2s2-0.9,2-2C64,60.6,63.1,59.7,62,59.7z"/>
</svg>
关于html - 将 SVG 对齐到 sass 中的 div 的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39060892/
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: How to align a to the middle of the page 这是一个简单的问题,应该有一个简
我想知道如何在屏幕中央的ListView中生成2个itens。 class _CategoriesState extends State { List categories = ["Anterio
我需要修复 UICollectionView 的一个小问题,当在 6s 设备尺寸上时,我得到如下布局: 但是,我想知道将它们居中以使其成为两条线的最佳方法是什么,或者我应该将它们缩小一点以便可以放置其
我尝试在 UIImageView 中居中 CAShapeLayer 但没有成功,我找到了解决方案,将其(CAShapeLayer)添加到 UIVIew,然后将 UIVIew 添加到 ImageView
一直在从线性布局和相对布局切换,因为我想实现图像的居中。 显示图片:
* { margin:0; padding:0; } /** General Style Info **/ body { background: #003d4c; co
我目前正在尝试修改我在 Wordpress 上的 Royal Slider 插件 (http://dimsemenov.com/plugins/royal-slider/) 我的目标是将所有标题的文本
我已经坚持了一段时间,因此简化了我的要求。当您单击标记时,信息窗口将打开,当用户缩放时,我希望该标记位于 map 的中心。这不起作用,但我认为它很接近: function bindInfoWindow
/* Linked Styles */ body { padding: 0 !important;
这个问题在这里已经有了答案: How do I center floated elements? (12 个答案) 关闭 7 年前。
这个问题在这里已经有了答案: Is there an equivalent to background-size: cover and contain for image elements? (1
我试图让我的页眉停留在页面的中间,不管我在什么窗口大小。 我试过使用 Bootstrap。 StackOverflow 还有这个 CSS。 .section-t
我有一个 1600 像素宽的页面。主要区域虽然只有 900 像素宽。我有一个导航应该固定在页面的中心(它是)。我的问题是当我打开页面时,页面固定在左侧而不是在打开时居中。当用户访问该网站时,我需要做什
我正在尝试找到 View 的中心。对于非旋转 View ,该值是正确的,但对于旋转 View ,它不正确,因为中心 (0,0) 正在旋转。在缩放的情况下,即使缩放后宽度和高度也保持不变 我正在使用以下
预期效果是将 Kartennummer 和 Passwort 集中。 这怎么可能? 我为此使用了一个自定义类: import 'package:flutter/material.dart'; impo
我管理着许多 Maven 项目。他们中的大多数部署到我们的内部 maven 存储库。现在我想开始向 Maven Central 发布一个项目。到目前为止,我有一个父 POM,它指定了我们内部存储库的
我试图锚定两个进展,但我看不到获得预期结果的方法。 我希望左边的进度条固定在左边,右边的条固定在中心固定(如下图所示) (下图显示调整大小的表格) 我尝试将控件放在具有各种 anchor 的停靠面板上
我正在玩 Angular 模态 ui 对话框。我想知道有什么方法可以让它居中?我发现了一个类似的问题: Twitter Bootstrap - Center Modal Dialog 但无法使其工作,
是否可以将值标签放置在条形上,使它们位于条形的中心? 如果我设置条形 align: "center",则条形上的标签将关闭且不居中。 $(function() { var d
http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-s
我是一名优秀的程序员,十分优秀!