我一直在開發一個小模板,這是我的 CSS 導致問題的條目:
body {
background-color: #D6ECEF;
font-family: Helvetica, sans-serif;
}
header.commerce1 {
background-color: #D2691E;
color: #FFFF;
border-radius: 5px;
padding: 22px;
}
a {
text-decoration: none;
}
div.content {
background-color: #FFF;
width: 860px;
}
body {
font-family: sans-serif;
}
ul.stock {
display: flex;
flex: 1 0 20%;
flex-grow: 3;
flex-wrap: wrap;
flex-basis: 100%;
width: 800px;
margin-left: 16px;
margin-top: -40px;
list-style: none;
margin: 1px;
justify-content: space-between;
}
ul.stock li {
font-family: sans-serif;
font-size: 88%;
color: #333;
background-color: #FFF;
column-gap: 3px;
border: 3px solid;
margin-left: 40px;
margin-bottom: 10px;
max-height: auto;
width: 250px;
margin-right: 0px;
margin: 0 0 20px 0;
justify-content: flex-end;
}
ul.stock li h3 {
font-size: 1.2em;
}
/*
ul.dealers li h3 {
color: red;
}
*/
ul.stock li p {
font-size: 0.75rem;
width: 230px;
white-space: initial;
padding: 3px;
margin-right: 20px;
}
ul.stock li img {
height: 180px;
}
a {
text-decoration: none;
}
hr {
height: 1px;
background-color: #a2a9b1;
border: 0;
margin: 0.2em 0
}
p {
margin: 0.4em 0 0.5em 0
}
p img {
margin: 0
}
ul {
margin: 0.3em 0 0 1.6em;
padding: 0
}
ol {
margin: 0.3em 0 0 3.2em;
padding: 0;
list-style-image: none
}
li {
margin-bottom: 0.1em
}
dt {
font-weight: bold;
margin-bottom: 0.1em
}
dl {
margin-top: 0.2em;
margin-bottom: 0.5em
}
dd {
margin-left: 1.6em;
margin-bottom: 0.1em
}
h3,
h4,
h5,
h6 {
margin: 30px 0 0
}
h2,
h3,
h4,
h5,
h6 {
padding: 0;
position: relative
}
/*
h2 {
font-size:18pt;
line-height:24pt;
margin-bottom:0.25em
}
h3 {
font-size:14pt;
line-height:20pt
}
h4,
h5,
h6 {
font-size:12pt;
line-height:16pt
}
*/
h2 {
line-height: 24pt;
margin-bottom: 0.25em;
}
h3 {
line-height: 20pt;
}
h4,
h5,
h6 {
line-height: 16pt;
}
ol,
ul {
margin: 10px 0 0 1.6em;
padding: 0
}
ol li,
ul li {
padding: 2px 0;
font-size: 12pt
}
q {
quotes: '"' '"' "'" "'"
}
blockquote {
overflow: hidden;
margin: 1em 0;
padding: 0 40px
}
h3 {
margin-top: 10px;
}
hr.archive-aex {
border: 5px dotted #ff0000;
border-style: none none dotted;
color: #fff;
background-color: #fff;
}
#content {}
[id="Content"] {
font-size: 14px;
}
.mw-body {
padding: 1.25em 1.5em 1.5em 1.5em;
}
.mw-body {
margin-top: -1px;
border: 1px solid #a7d7f9;
border-right-width: 0;
}
[id="bodyContent"] p,
.vector-body p {
margin: 0.5em 0;
}
[id="bodyContent"],
.vector-body {
font-size: calc(1em * 0.875);
line-height: 1.6;
}
div.stockimg img {
width: 250px;
}
<header class="commerce1">
<h2>MY AUCTION SITE TEMPLATE</h2>
</header>
<div class="content">
<h3>T-SHIRTS SALE</h3>
<ul class="stock">
<li>
<div class="stockimg">
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e6/LIOR_FOR_ATHENA.JPG">
<p><b>Women's T-shirt</b>, white <b>WAS £10.00 NOW £5.00</b>
</li>
<li>
<div class="stockimg">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/11_p_edit_edit.jpg/800px-11_p_edit_edit.jpg">
</div>
<p><b>Men's blue T-shirt</b>, Size M <b>WAS £8.00 NOW £5.00</b>
</li>
</ul>
</div>
來自開發網站的圖片:

如果 ul 類股票在串列中有三個專案,則空間不大,但如果只有兩個,則空間很大。
我一直在嘗試使用邊距,如果有兩行,它之間的差距仍然很大。
我怎樣才能修復邊距,以便如果串列中只有兩個專案它不是一個巨大的差距,目前我一直在嘗試修復差距、列等?
uj5u.com熱心網友回復:
這是由于您的flex justification是space-between,它在專案之間分配了均勻的空間。這就是為什么兩個串列會導致比三個更大的差距。
嘗試justify-content: flex-start在您的上使用ul并添加您希望作為保證金的值作為差距(例如,gap: 1rem)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/411385.html
標籤:
上一篇:添加直接IMG鏈接會中斷模板
