Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

html - Fixed column gap css

I am trying to make a layout where divs fall into a columns each with width 250px, so wider screens have more columns. I also want the gap between the columns to remain the same in this case 5px. The problem is when I readjust the width of the screen the gap changes in size (although the columns remain 250px and a new one is added or removed when there is enough extra space).

The extra space when I expand the screen to when a new column is rendered should go on either side of the column container;

My container is the following:

#my-pages-list-holder-new-fu{
    overflow-y: scroll;  
    column-width: 250px;
    justify-content: center;
    column-gap: 5px;
    
    
}
//my blocks which fall into the columns have this code:
.post-wrapper-tue{
    height: fit-content;
    width:250px;
    margin-bottom: 10px;
    -webkit-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
    -moz-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
    box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this:

<style>

#my-pages-list-holder-new-fu{
    overflow-y: scroll;  
    column-width: 250px;
    justify-content: center;
    column-gap: 2vw;
}

/* my blocks which fall into the columns have this code: */

.post-wrapper-tue{
    height: fit-content;
    width:250px;
    margin-bottom: 10px;
    -webkit-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
    -moz-box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
    box-shadow: 1px 3px 18px -9px rgba(0,0,0,0.2);
}

</style>

<div id="my-pages-list-holder-new-fu">
<div class="post-wrapper-tue">
<text>Ze Block</text>
</div>
<div class="post-wrapper-tue">
<text>Ze Other Block</text>
</div>
<div class="post-wrapper-tue">
<text>Ze Other Other Block</text>
</div>
</div>

If this doesn't work please keep in mind I could not properly test it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...