简体   繁体   English

SVG 网格和文本

[英]SVG Grid & Text

I am customizing a Ghost theme to create a 2 column/2 row grid with svg images, urls, and text centered below.我正在自定义一个 Ghost 主题以创建一个 2 列/2 行的网格,其中包含 svg 个图像、URL 和位于下方的文本。

A work in progress can be seen at https://country-musicfy.ghost.io/home正在进行的工作可以在https://country-musicfy.ghost.io/home 查看

I cannot figure out how to make the svg images the same height, nor make the text below centered and 20px我无法弄清楚如何使 svg 图像具有相同的高度,也无法使下面的文本居中和 20px

I am open to creating buttons with the svg images and text if anyone has suggestions.如果有人有建议,我愿意使用 svg 图像和文本创建按钮。

Below is html and css:下面是html和css:

<div class="row"> 
<div class="column">
<a href="https://country-musicfy.ghost.io/lofi"><img src="https://country- 
musicfy.ghost.io/content/images/2022/03/music-alt.svg" width="100%" loading="lazy" 
class="svg-icon" class="svg-text" alt=""><p>LoFi 128</p></a>
</div>
<div class="column">
<a href="https://country-musicfy.ghost.io/prime"><img src="https://country- 
musicfy.ghost.io/content/images/2022/03/music.svg" width="100%" loading="lazy" 
class="svg-icon" alt=""></a>
</div>
<div class="column">
<a href="https://country-musicfy.ghost.io/hifi"><img src="https://country- 
musicfy.ghost.io/content/images/2022/03/speaker.svg" width="100%" loading="lazy" 
class="svg-icon" alt=""></a>
</div>
<div class="column">
<a href="https://country-musicfy.ghost.io/master"><img src="https://country- 
musicfy.ghost.io/content/images/2022/03/headphones-alt.svg" width="100%" loading="lazy" 
class="svg-icon" alt=""></a>
</div>
</div>


<style>
/* Two image containers (use 25% for four, and 50% for two, etc) */
.column {
float: left;
width: 50%;
padding: 5px;
background: #282A2D;
}
.svg-icon {filter: invert(65%) sepia(14%) saturate(3161%) hue-rotate(185deg) 
brightness(103%) contrast(105%);}

.svg-text {
text-align: justify;
width: 100%;
}

/* Clear floats after image containers */
.row::after {
content: "";
clear: both;
display: table;
}
</style>

You can use CSS Flexbox to reach that easily.您可以使用 CSS Flexbox 轻松到达。 Please take a look to the code below.请查看下面的代码。 Then if you want, you can play with the height or padding of the text below the svg image or size of the image itself.然后,如果需要,您可以调整 svg 图像下方文本的高度或填充或图像本身的大小。

 /* Two image containers (use 25% for four, and 50% for two, etc) */.kg-canvas { justify-items: center; }.row { width: 100%; display: flex; text-align: center; flex-wrap: wrap; }.column { background: #282A2D; margin: 0; flex-basis: 50%; }.column a { display: flex; flex-direction: column; padding: 10px; }.svg-icon {filter: invert(65%) sepia(14%) saturate(3161%) hue-rotate(185deg) brightness(103%) contrast(105%); height: 100px; }.svg-text { text-align: justify; width: 100%; } /* Clear floats after image containers */.row::after { content: ""; clear: both; display: table; }
 <div class="row"> <div class="column"> <a href="https://country-musicfy.ghost.io/lofi"><img src="https://country-musicfy.ghost.io/content/images/2022/03/music-alt.svg" width="100%" loading="lazy" class="svg-icon" class="svg-text" alt=""><p>LoFi 128</p></a> </div> <div class="column"> <a href="https://country-musicfy.ghost.io/prime"><img src="https://country-musicfy.ghost.io/content/images/2022/03/music.svg" width="100%" loading="lazy" class="svg-icon" alt=""><p>LoFi 128</p></a> </div> <div class="column"> <a href="https://country-musicfy.ghost.io/hifi"><img src="https://country-musicfy.ghost.io/content/images/2022/03/speaker.svg" width="100%" loading="lazy" class="svg-icon" alt=""><p>LoFi 128</p></a> </div> <div class="column"> <a href="https://country-musicfy.ghost.io/master"><img src="https://country-musicfy.ghost.io/content/images/2022/03/headphones-alt.svg" width="100%" loading="lazy" class="svg-icon" alt=""><p>LoFi 128</p></a> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM