CSS curved arrow - html

trying to achieve something similar to the below with CSS. The icon itself
I currently have it looking like this:
Code looks as follows:
.homepage-wrapper {
border: 1px solid #d07028;
width: 100%;
border-radius: 4px;
}
.homepage-body {
display: table-cell;
padding-left: 20px;
height: 80px;
}
.homepage-dispatch {
padding: 20px;
width: 100px;
display: table-cell;
background-color: #862632;
background-image: url('../Images/homepage/shipping.png');
background-repeat: no-repeat;
background-position: center;
}
<div class="homepage-wrapper">
<div class="homepage-dispatch">
</div>
<div class="homepage-body">
Same Day Dispatch before 12pm
</div>
</div>
I haven't bothered to include any attempted CSS on the arrow portion because it doesn't look right at all.
Any tips would be appreciated!

For a pure CSS solution, you can overlay 2 rounded pseudo elements to form the arrow.
It involves some math to position them properly.
.homepage-wrapper {
--arrow-radius: 10px;
--arrow-size: 100px;
--arrow-color: #862632;
width: 300px;
display: grid;
grid-template-columns: auto auto;
grid-template-rows: 10px auto 10px;
}
.homepage-dispatch {
grid-column: 1/1;
grid-row: 1/-1;
width: var(--arrow-size);
height: var(--arrow-size);
background-color: var(--arrow-color);
border-top-right-radius: var(--arrow-radius);
border-bottom-right-radius: var(--arrow-radius);
display: grid;
grid-template-columns: auto;
grid-template-rows: auto;
justify-items: end;
background-image: url(https://i.stack.imgur.com/2JBwD.png);
background-repeat: no-repeat;
background-position: center;
}
.homepage-dispatch::before,
.homepage-dispatch::after {
content: "";
display: block;
width: calc((var(--arrow-size) - var(--arrow-radius)*2) * 0.57735 + 2 * var(--arrow-radius));
height: calc((var(--arrow-size) - var(--arrow-radius)*2) * 0.57735 + 2 * var(--arrow-radius));
grid-column: 1 / 1;
grid-row: 1 / 1;
background-color: var(--arrow-color);
border-radius: var(--arrow-radius);
position: relative;
z-index: -1;
}
.homepage-dispatch::before {
align-self: start;
transform-origin: calc(100% - var(--arrow-radius)) var(--arrow-radius);
transform: rotate(-30deg);
}
.homepage-dispatch::after {
align-self: end;
transform-origin: calc(100% - var(--arrow-radius)) calc(100% - var(--arrow-radius));
transform: rotate(30deg);
}
.homepage-body {
grid-column: 1/-1;
grid-row: 2;
border: 1px solid var(--arrow-color);
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
height: 100%;
padding-left: calc(var(--arrow-size) * 1.3 - 0.5 * var(--arrow-radius) + 20px);
padding-right: 20px;
display: flex;
flex-direction: column;
justify-content: center;
font-family: sans-serif;
text-align: center;
}
<div class="homepage-wrapper">
<div class="homepage-dispatch">
</div>
<div class="homepage-body">
Same Day Dispatch before 12pm
</div>
</div>
<hr>
<div class="homepage-wrapper" style="--arrow-color: blue;--arrow-size: 120px;--arrow-radius: 20px;">
<div class="homepage-dispatch">
</div>
<div class="homepage-body">
Same Day Dispatch before 12pm
</div>
</div>

Related

How can I make this square-inside-square structure horizontal?

I'm trying to represent this structure horizontaly, but I'm having some issues on what should I change so that this can work properly. What I hope to achieve is that those small squares in the bottom appear the same, only verticaly, on top of each other, while the bigger square keeps it's model.
.date-grid {
width: 120px;
height: 100px;
display: flex;
flex-direction: column;
}
.node {
width: 100%;
height: 100%;
background: #e9ecef;
border: none;
padding: 0;
}
time {
display: block;
height: 75%;
font-size: 24px;
display: flex;
flex-direction: column;
justify-content: center;
}
.smallHolder {
width: 100%;
height: 25%;
display: flex;
}
.smallHolder>div {
width: 25%;
height: 100%;
flex-shrink: 0;
flex-grow: 1;
}
.next { background: #0060df; }
.last { background: #d53343; }
<div class="date-grid">
<button class="node">
<time>3</time>
<div class="smallHolder">
<div class="next"></div>
<div class="last"></div>
</div>
</button>
</div>
Is this the sort of thing you're looking for? grid is great for this sort of thing.
.date-grid {
height: 100px;
display: grid;
grid-template-columns: 120px 25px;
grid-template-rows: 1fr 1fr;
grid-template-areas: "gray next" "gray last";
padding: 0;
border-style: none;
}
.gray {
grid-area: gray;
display: grid;
place-content: center;
background: #e9ecef;
}
time {
font-size: 24px;
}
.next {
grid-area: next;
background: #0060df;
}
.last {
grid-area: last;
background: #d53343;
}
<button class="node date-grid">
<time class='gray'>3</time>
<div class="next"></div>
<div class="last"></div>
</button>

Align a div container at the bottom of an image

I can't align a div container at the bottom of an image.
What I've tried is editing the attribute position of the image and set it's value to "relative".
Explaining this is a little bit difficult, but I got html and css code snippets with a little preview:
codepen.io/Proudyy/pen/PoOjYpK
(it's not 84 lines long, so not too much in my opinion)
This is how it should look like:
https://imgur.com/a/LShx2cM
set position: absolute for .skin-item-footer and position: relative on it's parent div. Check below code
.skin-item-splashart {
width: 100%;
border-radius: 12px;
position: relative;
}
.skin-item-footer-left-container {
grid-column: 1;
display: grid;
grid-template-rows: repeat(2, auto);
align-self: start;
height: 100%;
}
.skin-item-footer-right-container {
grid-column: 2;
display: grid;
align-items: center;
justify-content: end;
align-self: end;
height: 100%;
}
.skin-item-default-name {
font-size: 24px;
font-weight: bold;
margin-left: 3vh;
}
.skin-item-name {
font-size: 18px;
color: gainsboro;
margin: 0;
margin-left: 3vh;
grid-row: 1;
}
.skin-item-cost {
display: grid;
grid-row: 2;
grid-template-columns: repeat(2, auto);
grid-template-rows: 1fr;
}
.skin-item-cost-value {
color: gainsboro;
grid-column: 1;
margin: 0;
}
.skin-item-cost-icon {
grid-column: 2;
margin: 0;
}
.skin-item-save-icon {
cursor: pointer;
margin-right: 2vh;
}
.skin-item {
background-color: rgb(0, 40, 75);
margin: 15px;
border-radius: 12px;
height: auto;
width: 50%;
position: relative;
}
img{
max-width: 100%;
}
.skin-item-footer {
background-color: rgba(0, 0, 0, 0.4);
border-radius: 0 0 12px 12px;
position: absolute;
bottom: 0;
height: auto;
width: 100%;
}
<div class="skin-item">
<img class="skin-item-splashart" src="https://cdn.communitydragon.org/latest/champion/1/splash-art/skin/1"/>
<div class="skin-item-footer">
<div class="skin-item-footer-left-container">
<p class="skin-item-name">SkinName</p>
<div class="skin-item-cost">
<img class="skin-item-cost-icon" src="https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-static-assets/global/default/images/icon-rp-24.png"/>
<p class="skin-item-cost-value">Spaceholder</p>
</div>
</div>
<div class="skin-item-footer-right-container">
<img class="skin-item-save-icon" src="https://img.icons8.com/color/32/000000/save--v1.png"/>
</div>
</div>
</div>

flex can't use two justify for one div

I need a card list layout for this I use flex. in large device everything is ok but when device becomes small and two cards can't be next to each other and go to the next line, my content it's not center
in other words, I need to center my content in all device size and when two cards come together should be space-between and center
.container-card {
background-color: grey;
direction: rtl;
}
.container-holder {
background-color: gold;
width: calc(100% - 28px);
max-width: 1004px;
margin: auto;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
.request-box {
width: 481px;
height: 417px;
border-radius: 15px;
border: solid 1px #adadad;
background-color: #ffffff;
margin-top: 15px;
margin-bottom: 15px;
margin: 15px 2px;
}
<div class="container-card">
<div class="container-holder">
<div class="request-box"></div>
<div class="request-box"></div>
<div class="request-box"></div>
</div>
</div>
Please check the example above in full-page and change the responsive size
Hope this is helpful for you all in center align and i`m not use any mediaquery same code work on small screens .
.container-card {
background-color: grey;
}
.container-holder {
background-color: #ffd700;
width: calc(100% - 28px);
max-width: 1004px;
display: flex;
justify-content: space-around;
flex-wrap: wrap;
margin: 0 auto;
text-align: center;
}
.request-box {
width: 481px;
height: 417px;
border-radius: 15px;
border: solid 1px #adadad;
background-color: #ffffff;
margin-top: 15px;
margin-bottom: 15px;
margin: 15px 2px;
}
<div class="container-card">
<div class="container-holder">
<div class="request-box"></div>
<div class="request-box"></div>
<div class="request-box"></div>
</div>
</div>
Use CSS grid for this:
.container-card {
background-color: grey;
direction: rtl;
}
.container-holder {
background-color: gold;
width: calc(100% - 28px);
max-width: 1004px;
margin: auto;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(481px, 1fr));
place-items: center;
grid-column-gap: 30px;
}
.request-box {
width: 481px;
height: 417px;
border-radius: 15px;
border: solid 1px #adadad;
background-color: #ffffff;
margin: 15px 0;
}
<div class="container-card">
<div class="container-holder">
<div class="request-box"></div>
<div class="request-box"></div>
<div class="request-box"></div>
</div>
</div>
to set the cards netx to each other in small devices you can use this media query:
#media(max-width: 400px){
.container-holder {
justify-content: space-around;
}
.request-box {
width: 45%;
}
}
test it . it works nicely!

Image spilling out of parent div in CSS Grid item (Firefox only)

Is there a better way to achieve centering a text caption on an image that is nested in a CSS Grid item (and can be "justify-items: start/end/etc")
I like how the example is rendering in Safari & Chrome but in Firefox the image is spilling out of the parent div. Any help would be greatly appreciated! Thank you :)
Safari / Chrome Example
Firefox Example (Image spilling out of parent div)
https://codepen.io/jcha4849/pen/ywgMde
<body>
<div class="container-main"><article id="post-number-1">
<div class="standard-container-1">
<div class="caption-1">CENTERED CAPTION 1</div>
<img src="https://images.unsplash.com/photo-1516472096803-187d3339b36f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80"></div>
</article>
<article id="post-number-2">
<div class="standard-container-1">
<div class="caption-1">CENTERED CAPTION 2</div>
<img src="https://images.unsplash.com/photo-1516472096803-187d3339b36f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80"></div>
</article>
</div>
<!-- container-main -->
</body>
<style>
body {
padding: 0;
margin: 0;
}
.container-main {
width: 100%;
display: grid;
grid-template-columns: repeat(10, 9vw);
grid-auto-rows: 9vw;
margin: 0 0 0px 0;
padding: 0;
min-width: 0;
padding: 5vw 5vw 15vw 5vw;
min-width: 0;
background-color: teal;
}
.container-main article {
border: 3px solid black;
}
.container-main article .standard-container-1 {
position: relative;
max-height: 100%;
max-width: 100%;
}
.container-main article .standard-container-1 .caption-1 {
min-width: 80%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.container-main article .standard-container-1 .caption-1 a {
color: #0f0;
font-family: sans-serif;
}
.container-main article .standard-container-1 img {
display: block;
height: auto;
margin: 0 auto;
max-height: 100%;
max-width: 100%;
}
.container-main article#post-number-1 {
display:grid;
align-items: start;
justify-items: start;
grid-column: 1 / 4;
grid-row: 1 / 4 ;
}
.container-main article#post-number-2 {
display:grid;
align-items: start;
justify-items: end;
grid-column: 8 / 11;
grid-row: 1 / 4 ;
}
</style>

I cant get CSS grids to line up

I got my header to work fine, however I cant get my pictures to follow my columns. Basically in the code below I want .left and .mid to line up horizontally ( and there is going to be a 3rd picture as well) Right now they are lining up vertically. I think I might be doing something wrong with the column set up but I am not sure
#import url('https://fonts.googleapis.com/css?family=Sofia');
body {
margin: 0;
}
nav {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-auto-rows: auto;
grid-gap: 1em;
align-items: center;
text-align: center;
/*border-bottom: 4px solid black;*/
background:#0066cc;
}
#media screen and (max-width: 900px) {
nav {
grid-template-columns: 100%;
grid-template-rows: auto;
grid-gap: 1em;
}
}
.1 {
grid-column: 1;
}
.2 {
grid-column: 2;
}
.logo {
grid-column: 3;
background-image: url("images/cocinaheader.png");
background-position: center;
background-size: contain;
background-repeat: no-repeat;
height: 6vh;
}
.3 {
grid-column: 4;
}
.4 {
grid-column: 5;
}
.navLinks {
font-family: 'Sofia';
font-size: 1.2em;
text-transform: uppercase;
text-decoration: none;
color: black;
}
.navLinks:hover {
color: white;
border-left: 1px solid white;
border-right: 1px solid white;
padding: 1em 1em;
}
#twist {
color: blue;
}
banner {
padding: 1em 1em;
display: grid;
grid-template-rows: 100%;
}
.bannerlogo{
grid-row: 1;
/*background-image: url(images/banner.jpg);*/
background-position: center;
background-size: contain;
background-repeat: no-repeat;
width: 100%;
height: 100%;
}
.h1{
font-family: 'Sofia';
font-size: 1em;
text-transform: uppercase;
color: black;
}
block {
display: grid;
grid-template-columns:20% 20% 20% 20% 20%;
/*grid-auto-rows: auto;*/
grid-gap: 1em;
align-items: center;
}
.left {
grid-column: 2;
background-image: url("images/foodleft.png");
background-position: center;
background-size: contain;
background-repeat: no-repeat;
height: 20vh;
}
.mid {
grid-column: 3;
background-image: url("images/foodmid.jpg");
background-position: center;
background-size: contain;
background-repeat: no-repeat;
height: 20vh;
}
<header>
<nav class="container">
<div class="1">
Home
</div>
<div class="2">
Menu
</div>
<div class="logo">
</div>
<div class="3">
About Us
</div>
<div class="4">
Contact Me
</div>
</nav>
</header>
<br><br><br><br>
<main>
<div class="banner">
<div class="bannerlogo">
<center>
<img src="images/banner.jpg">
</center>
</div>
<br><br><br><br><br><br>
<div class="h1">
<center><h1>A taste of our menu</h1></center>
</div>
<!-- Start block grid -->
<div class="block">
<div class="left"></div>
<div class="mid"></div>
</div>
You cannot use just numbers as class names in css. Try using .item1 .item2 etc...