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
248 views
in Technique[技术] by (71.8m points)

html - why does bootstrap affect grid-row-gap? Is there any way to prevent?

I wanted to use CSS grid system with Bootstrap. However, it seems they don't get on well with each other. grid-gap works partially well, which means grid-column-gap works just fine, but not grid-row-gap. I can solve this problem only by removing Bootstrap. Is there any way?

<style>
.gallery--images {
 display: grid;
 grid-template-columns: repeat(8, 1fr);
 grid-template-rows: repeat(8, 5vw);
 grid-gap: 0.2em;                                        
 margin-bottom: 10px;
 background: rgba(250, 250, 250, 0.575);
 background-clip: padding-box;
 backdrop-filter: blur(10px );
 border: 2px solid rgb(240, 240, 240);
 border-radius: 5px;
}
</style>


<div class="gallery--images">
    <figure class="gallery__item gallery__item--1">
        <img src="img/NewYorkCity-1.jpg" alt="Gallery image 1" class="gallery__img">
    </figure>
    <figure class="gallery__item gallery__item--2">
        <img src="img/NewYorkCity-1.jpg" alt="Gallery image 2" class="gallery__img">
    </figure>
    <figure class="gallery__item gallery__item--3">
        <img src="img/NewYorkCity-1.jpg" alt="Gallery image 3" class="gallery__img">
    </figure>
    <figure class="gallery__item gallery__item--4">
        <img src="img/NewYorkCity-1.jpg" alt="Gallery image 4" class="gallery__img">
    </figure>
    <figure class="gallery__item gallery__item--5">
        <img src="img/NewYorkCity-1.jpg" alt="Gallery image 5" class="gallery__img">
    </figure>
    <figure class="gallery__item gallery__item--6">
        <img src="img/NewYorkCity-1.jpg" alt="Gallery image 6" class="gallery__img">
    </figure>
</div>

https://codepen.io/Isya/pen/RwGXwjJ

question from:https://stackoverflow.com/questions/65896017/why-does-bootstrap-affect-grid-row-gap-is-there-any-way-to-prevent

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

1 Reply

0 votes
by (71.8m points)

This margin of figure tag breaks your grid-gap: 0.2em. It is necessary to override this rule. Add this to your css:

figure {
    margin: 0!important;
}

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

...