Im styling multiple boxes, it's only the first box whose top outline is not working. Here's my code. I'm using bootstrap in React. Border works. I have attached the relevent css.
EDIT: I hacked it by setting my outline-offset to negative the amount of pixels. so -3. Worked fine for me, and am wondering how it happened and how to avoid it.
.savedMeme--card {
display: grid;
grid-template-columns: 1fr 2fr;
grid-template-rows: 100%;
padding: 10px;
}
.savedMeme--card:hover {
background-color: #e3e3e3c4;
outline: 3px solid var(--blue);
}
<div className="offcanvas offcanvas-end" tabIndex="-1" id="sidebar" aria-labelledby="sidebar--header">
<div className="offcanvas-header">
<h2 className="offcanvas-title" id="sidebar--header">Your saved memes</h2>
<button className="btn-close" data-bs-dismiss="offcanvas" type="button" aria-label="Close"></button>
</div>
<div className="offcanvas-body p-0">
<div className="savedMeme--card">
<!-- this is an imported component -->
<div className="savedMeme--header">
<span className="bi bi-bookmark-x-fill"></span>
<img src={props.url} style={{ width: "80px", height: "80px" }} alt="meme" />
</div>
<div className="savedMeme-body">
<p>
{props.topText}...
</p>
<p className="savedMeme--view-meme">view meme</p>
</div>
</div>
</div>
</div>
</div>
</div>
I have fixed your closing div tag issue and changed className to class and just defined css variable
:root {
--blue: blue;
}
Everything seems to works fine on hover.
:root {
--blue: blue;
}
.savedMeme--card {
display: grid;
grid-template-columns: 1fr 2fr;
grid-template-rows: 100%;
padding: 10px;
}
.savedMeme--card:hover {
background-color: #e3e3e3c4;
outline: 3px solid var(--blue);
}
<div class="offcanvas offcanvas-end" tabIndex="-1" id="sidebar" aria-labelledby="sidebar--header">
<div class="offcanvas-header">
<h2 class="offcanvas-title" id="sidebar--header">Your saved memes</h2>
<button class="btn-close" data-bs-dismiss="offcanvas" type="button" aria-label="Close"></button>
</div>
<div class="offcanvas-body p-0">
<div class="savedMeme--card">
<!-- this is an imported component -->
<div class="savedMeme--header">
<span class="bi bi-bookmark-x-fill"></span>
<img src={props.url} style={{ width: "80px" , height: "80px" }} alt="meme" />
</div>
<div class="savedMeme-body">
<p>
{props.topText}...
</p>
<p class="savedMeme--view-meme">view meme</p>
</div>
</div>
</div>
</div>
Related
I need to put these divs into a grid so that they display on the screen in a grid as opposed to a block. I have them displayed in a block and centered on the screen for smaller screen widths and after a certain screen width I would like them to display as a grid, but I keep getting the buttons and text displaying to the right of the images as opposed to displaying under the images. Here is my HTML and CSS code...
<section>
<div class="container-2">
<div class="wrapper-2">
<div class="boxes" data-aos="fade-up" data-aos-duration="800">
<img src="https://atlas-content-cdn.pixelsquid.com/stock-images/shirt-men-181dmv4-600.jpg" alt="Image cannot be displayed">
<h2>Men's slim fit blue plaid shirt</h2>
<p>$50.00</p>
<button class="arrivals-buttons">Add to cart</button>
</div>
<p class="border-bottom"></p>
<div class="boxes" data-aos="fade-up" data-aos-duration="800">
<img src="https://watchdreamer.com/sites/default/files/styles/soldat_md/public/2021-05/WBP201A.BA0632_.png?h=7afb1587&itok=EH_sMV2B" alt="Image cannot be displayed">
<h2>Men's silver and black time piece</h2>
<p>$499.99</p>
<button class="arrivals-buttons">Add to cart</button>
</div>
<p class="border-bottom" data-aos="fade-right" data-aos-duration="800"></p>
<div class="boxes" data-aos="fade-up" data-aos-duration="800">
<img src="https://www.pngall.com/wp-content/uploads/5/Brown-Men-Shoes-PNG-Image.png" alt="Image cannot be displayed">
<h2>Men's Uncle Tom dress shoes</h2>
<p>$44.99</p>
<button class="arrivals-buttons">Add to cart</button>
</div>
<p class="border-bottom" data-aos="fade-right" data-aos-duration="800"></p>
<div class="boxes" data-aos="fade-up" data-aos-duration="800">
<img src="https://i5.walmartimages.com/asr/b19cdda5-932f-4862-a7b3-b7440bfb759e_1.87f4ae5495ec75a86d5f6e4572e807d3.jpeg?odnHeight=612&odnWidth=612&odnBg=FFFFFF" alt="Image cannot be displayed">
<h2>Men's slim black slim fit dress pants</h2>
<p>$70.00</p>
<button class="arrivals-buttons">Add to cart</button>
</div>
<p class="border-bottom" data-aos="fade-right" data-aos-duration="800"></p>
<div class="boxes" data-aos="fade-up" data-aos-duration="800">
<img src="https://www.suitsexpert.com/wp-content/uploads/2019/01/silk-tie.png" alt="Image cannot be displayed">
<h2>Men's formal red tie</h2>
<p>$19.99</p>
<button class="arrivals-buttons">Add to cart</button>
</div>
</div>
</div>
</section>
<style>
.container-2 {
width: 90%;
display: block;
margin: 0 auto 0 auto;
}
.boxes {
display: grid;
justify-content: space-evenly;
grid-template-columns: 220px 220px 220px;
}
</style>
You need to change .boxes class. When grid-template-columns property is used, it will create columns that put your text and button to the side of your image.
.boxes {
display: grid;
width: 50%;
margin: 0 auto;
}
Also, you can add width and height to your image so that it does not go out of the grid width.
You don't put display:grid; at the boxes you want to be a part of the grid. But you put it in the container. This would be an example
.container-2 {
display:grid;
gap:1rem;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
grid-template-rows: 200px;
}
then you can remove the .wrapper-2 element
I do have the following HTML output:
so, as you can see the footer isn't matching...
my css component looks like this:
.card-equal-height {
display: flex;
flex-direction: column;
height: 100%;
}
.card-equal-height
.card-footer {
margin-top: auto;
height: 100%;
}
.card-equal-height.card-footer this part is not working somehow. I want the footer to be matching the order cards, no matter how long the description is.
html:
<div [ngClass]="{'card-highlight': product.listItemHovered}" class="card card-equal-height"
(mouseenter)="hoverListItem(product)"
(mouseleave)="hoverListItem(product)"
(click)="test(product)">
<div class="card-image">
<figure class="image is-square">
<img [src]="product.imageURL" alt="{{product.title}}">
</figure>
</div>
<div class="card-content">
<p class="title has-text-centered"> {{product.title}}</p>
<p class="subtitle">{{product.price | currency: "USD"}}</p>
</div>
<div class="card-footer">
<p class="card-footer-item">
<button (click)="removeFromCart(product); showRemoved()"
class="button is-danger is-outlined is-pulled-left is-small"> Remove
</button>
</p>
<p class="card-footer-item">
<button (click)="addToCart(product);showAdded()"
class="button is-outlined is-primary is-pulled-right is-small"> Add to Cart
</button>
</p>
</div>
</div>
I think you can achieve changing the height of "card-content" (forget change the .card-footer) using flex-grow
.card-equal-height
.card-content {
flex-grow:1;
}
For more about flex, check this link in css-tricks
I'm using ngbootstrap and angular, but I think the problem here is more of html/css matter.
I want to make a container to scroll horizonstally, I've found few threads about it, but cannot make it work in my case...
Here's my code
html:
<div style="width: 100%; background-color: rgb(177, 177, 177);">
<div class="container" >
<div class="my-container">
<h1>Usługi</h1>
<p>Nasza firma posiada uprawnienia UDT w zakresie montażu i konserwacji urządzeń dźwigowych, w tym:</p>
<div class="col-12 horizonstall-scroll" style="margin-left: auto; margin-right: auto; padding: 0;">
<div class="row">
<div class="card-container d-flex justify-content-center" *ngFor="let item of items">
<div class="card my-card" style="width: 18rem;">
<img class="card-img-top" src="{{item.smallImg}}" alt="lift">
<div class="card-body">
<h5 class="card-title">{{item.name}}</h5>
<p class="card-text">{{item.shortDesc}}</p>
<a class="btn btn-primary" (click)="openModal(item)" >Czytaj więcej</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
css:
.my-container {
padding-left: 15px;
padding-right: 15px;
background-color: rgb(216, 209, 209);
box-shadow: 0px 10px 25px 13px rgba(0,0,0,0.75);
}
.horizonstall-scroll > .row {
overflow-x: auto;
white-space: nowrap;
}
.horizonstall-scroll > .row > .card-container {
display: inline-block;
float: none;
}
Hi maybe this might help because I have had this problem before and I fixed it using this solution and its using bootstrap which is better in your case
Horizontal scrollable div's in a bootstrap row
hope this solution helps your needs, Cheers :)
I've been stuck on this for ages now. I'm building a FAQ section which, on desktop, has to have 2 columns on which it fills it's FAQ items. The items have a dropshadow and the whole is made with Bootstrap 4.
I've tried Flexbox, CSS columns. Now i've tried CSS Grid, however i still have the problem that whenever i open an accordion the item on the other side also expands it's body. I included a pen to demonstrate this.
Update: Forgot an important detail. It's a Wordpress website, with the Advanced Custom Fields (ACF) plugin i created a repeater field. Which outputs the FAQ items as an array. Therefore the amount of items is always dynamic. They need to fill out 2 columns, unless there is only 1 item ofcourse.
The html is:
<ul id="faq-accordion" class="list-unstyled">
<li class="card-faq" data-toggle="collapse" data-target="#collapse1" aria-expanded="false" aria-controls="collapse1">
<div class="card-header" id="heading1">
<h3>
<button class="btn btn-link">Accordion 1</button>
</h3>
</div>
<div id="collapse1" class="collapse multi-collapse" aria-labelledby="heading1" data-parent="#faq-accordion">
<div class="card-body">contents
</div>
</div>
</li>
</ul>
My SCSS:
#faq-accordion{
padding: 40px 30px 60px 30px;
display: grid;
grid-gap: 30px;
grid-template-columns: repeat(2, 50%);
grid-template-rows: auto;
grid-auto-flow: row;
height: auto;
width: 500px;
.card-faq{
margin: 0 15px 20px 15px;
border: none;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0,0,0,.1);
}
The codepen: https://codepen.io/LemonNick/pen/NEjJPQ
Any help or suggestions would be appreciated! Been stuck on this for too long now.
if the only problem is, that the shadow is expanding, just wrap the contents of .card-faq in another div and move the shadow to there
#faq-accordion {
padding: 40px 30px 60px 30px;
display: grid;
grid-gap: 30px;
grid-template-columns: repeat(2, 50%);
grid-template-rows: auto;
grid-auto-flow: row;
height: auto;
width: 500px;
}
.card-faq {
margin: 0 15px 20px 15px;
}
.shadow {
border: none;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, .1);
}
<ul id="faq-accordion" class="list-unstyled">
<li class="card-faq" data-toggle="collapse" data-target="#collapse1" aria-expanded="false" aria-controls="collapse1">
<div class="shadow">
<div class="card-header" id="heading1">
<h3>
<button class="btn btn-link">Accordion 1</button>
</h3>
</div>
<div id="collapse1" class="collapse multi-collapse" aria-labelledby="heading1" data-parent="#faq-accordion">
<div class="card-body">contents
</div>
</div>
</div>
</li>
<li class="card-faq" data-toggle="collapse" data-target="#collapse1" aria-expanded="false" aria-controls="collapse1">
<div class="shadow">
<div class="card-header" id="heading1">
<h3>
<button class="btn btn-link">Accordion 1</button>
</h3>
</div>
<div id="collapse1" class="collapse multi-collapse" aria-labelledby="heading1" data-parent="#faq-accordion">
<div class="card-body">contents
</div>
</div>
</div>
</li>
</ul>
working in you codepen like so : https://codepen.io/anon/pen/gQWywr?editors=0100
Second isn't expanding it's body. But rather li is following height as it's in grid. You just need to replace shadow from li element to card-body. So from this one
#faq-accordion .card-faq
. I just checked body stays collapsed. But shadow from li element is making illusion.
Btw I have adjusted your pen
Perhaps you should consider using a couple of divs with a float on them:
<html>
<head>
<style>
.faq {
float:left;
}
</style>
</head>
<body>
<div class="faq"><!--Put your first column cards here--></div>
<div class="faq"><!--Put your second column cards here--></div>
</body>
</html>
I have a pretty simple setup for a web page, consisting of a grid of divs, headers, and i elements:
All I want to do is add a div with a background color and a header behind this grid, with the elements of the grid appear on top of the new background div.
However, when I try to do this, I get this:
As you can see, the transparent color of the background div is overlapping the buttons, only in the grid.
I've made sure to adjust the z-index of all elements (the background div, the grid and all of it's elements) so that they do have higher z-index value than the background div.
Here is my HTML and CSS:
HTML
<html>
...
<body>
<div id="sfa3features"><h1>New SFA3 Features!</h1></div>
...
<div class="wrapper-how-to" id="grid-menu3">
<div class="row-top"></div>
<h2 class="row-top label-cell">Setting</h2>
<div class="row-top"></div>
<div class="row-top"></div>
<div class="row-top"></div>
<div class="row-top"></div>
<i class="image-cell fa fa-info-circle fa-2x"></i>
<h3 class="label-cell">Combo Items</h3>
<div id="combo_items_finding" class="box-how-to enabled"><h3>Finding</h3> <span class="popup popup-how-to" id="popup_combo_items_finding" > </div>
<div id="combo_items_updating" class="box-how-to impossible"><h3>Updating</h3> <span class="popup popup-how-to" id="popup_combo_items_updating" ></div>
<div id="combo_items_entering" class="box-how-to enabled"><h3>Entering</h3> <span class="popup popup-how-to" id="popup_combo_items_entering" ></div>
<div id="combo_items_linking" class="box-how-to impossible"><h3>Linking</h3><span class="popup popup-how-to" id="popup_combo_items_linking" ></div>
</div>
<div class="wrapper-how-to" id="grid-menu4">
<div class="row-top"></div>
<h2 class="row-top label-cell">Pickbox</h2>
<div class="row-top"></div>
<div class="row-top"></div>
<div class="row-top"></div>
<div class="row-top"></div>
<i class="image-cell fa fa-folder-o fa-2x"></i>
<h3 class="label-cell">Pickbox</h3>
<div id="pickbox_finding" class="box-how-to enabled"><h3>Finding</h3> <span class="popup popup-how-to" id="popup_pickbox_finding" > </div>
<div id="pickbox_updating" class="box-how-to enabled"><h3>Updating</h3> <span class="popup popup-how-to" id="popup_pickbox_updating" ></div>
<div id="pickbox_entering" class="box-how-to enabled"><h3>Entering</h3> <span class="popup popup-how-to" id="popup_pickbox_entering" ></div>
<div id="pickbox_linking" class="box-how-to impossible"><h3>Linking</h3><span class="popup popup-how-to" id="popup_pickbox_linking" ></div>
</div>
...
</body>
</html>
CSS
.wrapper-how-to {
display: grid;
grid-gap: 10px;
grid-template-columns: 5% 22% 16% 16% 16% 16%;
background-color: transparent;
color: #444;
margin: 2.5% auto !important;
}
.wrapper-how-to h2,
.wrapper-how-to h3,
.wrapper-how-to div,
.wrapper-how-to i
{
z-index:2;
}
#sfa3features{
/*Should be the same as coverup5, but back layer*/
display: flex;
position: absolute;
width: 105%;
left:-4%;
align-items: flex-start;
justify-content: center;
background-color: rgba(255, 219, 89,0.8);
border-color: rgb(252, 204, 30);
border-style: solid;
border-radius: 8px;
border-width: 5px;
z-index: -1;
height: 400px;
top:1485px;
}
Any idea what's going on?
I was getting confused. The div elements have a transparent color. Of course they will use the background div's color as well.
Switching CSS to opaque colors should solve the problem.
Had the same problem, it really was because I was using an transparent color.