我对一般的css和网页开发是个新手.我的经验是使用Python.我有一个问题,容器包含在一个网格视图中,没有遵守我在右边或左边添加的任何边距、填充或间隙.它的顶部和底部都很好,但我try 的所有东西都不适用于右侧和左侧.
/* CSS style for my container.*/
.results-container {
text-align : left;
background-color : var(--container-color);
/* Background color of the container */
color : var(--text-color);
border-radius : 5px; /* Rounded corners */
padding : 10px; /* Spacing inside the container */
max-width : 100%;
width : 100%;
box-shadow : 0px 0px 10px rgba(0, 0, 0, 0.7); /* Add a shadow for visual effect */
display : flex;
flex-direction : column;
margin : 10px;
}
/* The style for the Grid View. */
.grid-container {
display : grid;
grid-template-columns : repeat(3, 1fr); /* Automatically decide the number of columns based on screen width */
margin : 20px;
gap : 20px;
justify-items : center;
align-items : center;
padding : 0 10px;
}
<div class="grid-container">
<div class="results-container">
<h4 class="song-name">Testing Container</h4>
<p class="song-info">Author: Casey Koehn</p>
<p class="song-info">First Verse: Test verse here</p>
<p class="song-info">Chorus: Test chorus here</p>
</div>
<div class="results-container">
<h4 class="song-name">Testing Container</h4>
<p class="song-info">Author: Casey Koehn</p>
<p class="song-info">First Verse: Test verse here</p>
<p class="song-info">Chorus: Test chorus here</p>
</div>
<div class="results-container">
<h4 class="song-name">Testing Container</h4>
<p class="song-info">Author: Casey Koehn</p>
<p class="song-info">First Verse: Test verse here</p>
<p class="song-info">Chorus: Test chorus here</p>
</div>
<div class="results-container">
<h4 class="song-name">Testing Container</h4>
<p class="song-info">Author: Casey Koehn</p>
<p class="song-info">First Verse: Test verse here</p>
<p class="song-info">Chorus: Test chorus here</p>
</div>
<div class="results-container">
<h4 class="song-name">Testing Container</h4>
<p class="song-info">Author: Casey Koehn</p>
<p class="song-info">First Verse: Test verse here</p>
<p class="song-info">Chorus: Test chorus here</p>
</div>
</div>
Inspector Screenshot
Problem Screenshot
我try 在容器中添加边距,在网格视图中填充,在网格视图中添加间隙,并try 移除方框阴影,但都没有效果.正如前面提到的,我是网络开发人员的新手,还在学习中.这可能是一个我没有注意到的非常简单的错误.