Here I'm trying to position an SVG icon over a CSS border, but I'm facing a problem with the CSS border. As per the design, the border should be in the background, and the icon will be in front. I'm trying to solve using z-index!
Design
Output
.se-venue-cta {
width: 300px;
text-align: center;
margin: 5% auto;
background: #000;
background: #FFF1EA;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);
padding: 20px;
position: relative;
z-index: 2;
}
.se-venue-cta-text p {
color: #FE6F48;
text-align: center;
}
.se-venue-cta-text {
border: 2px solid #FE6F48;
border-radius: 10px;
margin-bottom: 30px;
}
.se-venue-cta-btn {
height: 44px;
}
.se-venue-cta-btn a {
transition: all 0.3s ease-in-out;
display: flex;
background: #FE6F48;
border-radius: 6px;
height: 100%;
justify-content: center;
align-items: center;
text-decoration: none;
color: #ffffff;
font-weight: bold;
font-size: 16px;
}
span {
display: block;
position: absolute;
left: 50%;
top: 8px;
transform: translateX(-50%);
z-index: 999;
overflow: hidden;
}
<div class="se-venue-cta">
<div class="se-venue-cta-text">
<p> The average wedding costs $33,900. Get a quote now and let us plan you a beautiful elopement, while saving you over $28,000</p>
</div>
<div class="se-venue-cta-btn">
Get a Quote
</div>
<!-- svg icon -->
<span>
<svg width="20" height="27" viewBox="0 0 20 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.7889 15.4035C12.6086 15.6051 12.4191 15.798 12.2211 15.9818C11.6767 15.1346 11.5056 13.9309 11.8133 12.8475C12.0244 12.1027 12.5644 11.1263 13.39 10.8225C14.1 10.5615 14.6111 11.1791 14.6856 11.8305C14.8344 13.1242 12.79 15.4035 12.79 15.4035H12.7889ZM13.1056 18.3938C13.9133 18.7054 14.7944 18.7301 15.7156 18.4556C16.3041 18.2729 16.8621 18.0017 17.3711 17.6512C14.41 22.5911 10 27 10 27C10 27 5.66778 22.6688 2.70556 17.7806C3.57333 17.4521 4.46778 16.5656 5.37333 15.129C5.97556 14.175 6.55889 13.0028 7.03889 11.8046L7.1 11.9216C7.16667 12.0566 7.23556 12.1916 7.30444 12.3266C7.82667 13.3571 8.36778 14.4214 8.47111 15.4991C8.53444 16.1764 8.26444 16.3913 8.17445 16.4621C7.71889 16.8221 6.70778 16.8435 5.71222 16.5139C5.57924 16.4695 5.43609 16.4669 5.30162 16.5064C5.16715 16.546 5.04767 16.6259 4.95889 16.7355C4.87133 16.8441 4.81936 16.9777 4.8102 17.1176C4.80104 17.2575 4.83515 17.3969 4.90778 17.5163C5.63 18.6997 6.97444 19.1677 8.27222 19.1677C8.76111 19.1677 9.24333 19.1014 9.68333 18.9821C10.51 18.7571 11.3322 18.3622 12.1011 17.8301H12.1033C12.4105 18.063 12.7477 18.2523 13.1056 18.3926V18.3938ZM10 0C15.5222 0 20 3.49537 20 10.2487C20 10.8934 19.9089 11.5673 19.7444 12.2591C19.2233 14.1401 17.2956 16.5578 15.3222 17.1461C15.0599 17.2262 14.7883 17.2705 14.5144 17.2778C14.2898 17.283 14.0654 17.2569 13.8478 17.2001C13.6313 17.1424 13.4235 17.0554 13.23 16.9414L13.2122 16.9301C13.42 16.7355 13.6211 16.5296 13.8144 16.3136L13.8678 16.2551C14.9367 15.0626 16.2678 13.5776 16.05 11.6764C15.9544 10.8371 15.5111 10.1014 14.8644 9.70537C14.2844 9.34987 13.5922 9.29138 12.9133 9.54113C11.6067 10.0215 10.8056 11.3715 10.4911 12.4751C10.0611 13.9894 10.3244 15.6442 11.1378 16.8289C10.5778 17.2 9.96466 17.4815 9.32 17.6636C9.09778 17.7232 8.86556 17.7649 8.62889 17.7874C8.77111 17.7154 8.90445 17.6299 9.02889 17.532C9.46 17.1911 9.94889 16.5409 9.83778 15.372C9.71111 14.0355 9.08333 12.8003 8.53 11.7101L8.33 11.313C8.29087 11.2375 8.25086 11.1625 8.21 11.088C7.98778 10.6684 7.81 10.3151 7.67111 10.017L7.72667 9.86737C7.93778 9.30937 8.29 8.37337 7.66 7.70625C7.52713 7.56253 7.35976 7.4561 7.17419 7.39735C6.98862 7.3386 6.79118 7.32952 6.60111 7.371C6.44788 7.40464 6.30451 7.47403 6.18241 7.57363C6.06031 7.67323 5.96285 7.80031 5.89778 7.94475C5.68667 8.40825 5.77 9.0585 6.20333 10.0935C5.11 13.4179 3.13444 16.47 2.00222 16.5566C0.825556 14.3955 0 12.1882 0 10.2487C0 3.49537 4.47778 0 10 0Z" fill="#FF4816"/>
</svg>
</span>
</div>
Add background in span same as the background and add padding in it:
.se-venue-cta {
width: 300px;
text-align: center;
margin: 5% auto;
background: #000;
background: #FFF1EA;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);
padding: 20px;
position: relative;
z-index: 2;
}
.se-venue-cta-text p {
color: #FE6F48;
text-align: center;
}
.se-venue-cta-text {
border: 2px solid #FE6F48;
border-radius: 10px;
margin-bottom: 30px;
}
.se-venue-cta-btn {
height: 44px;
}
.se-venue-cta-btn a {
transition: all 0.3s ease-in-out;
display: flex;
background: #FE6F48;
border-radius: 6px;
height: 100%;
justify-content: center;
align-items: center;
text-decoration: none;
color: #ffffff;
font-weight: bold;
font-size: 16px;
}
span {
display: block;
position: absolute;
left: 50%;
top: 8px;
transform: translateX(-50%);
z-indix: 999;
overflow: hidden;
background
}
.svg-wrap {
background: #FFF1EA;
padding: 0 10px;
}
<div class="se-venue-cta">
<div class="se-venue-cta-text">
<p> The average wedding costs $33,900. Get a quote now and let us plan you a beautiful elopement, while saving you over $28,000</p>
</div>
<div class="se-venue-cta-btn">
Get a Quote
</div>
<!-- svg icon -->
<span class="svg-wrap">
<svg width="20" height="27" viewBox="0 0 20 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.7889 15.4035C12.6086 15.6051 12.4191 15.798 12.2211 15.9818C11.6767 15.1346 11.5056 13.9309 11.8133 12.8475C12.0244 12.1027 12.5644 11.1263 13.39 10.8225C14.1 10.5615 14.6111 11.1791 14.6856 11.8305C14.8344 13.1242 12.79 15.4035 12.79 15.4035H12.7889ZM13.1056 18.3938C13.9133 18.7054 14.7944 18.7301 15.7156 18.4556C16.3041 18.2729 16.8621 18.0017 17.3711 17.6512C14.41 22.5911 10 27 10 27C10 27 5.66778 22.6688 2.70556 17.7806C3.57333 17.4521 4.46778 16.5656 5.37333 15.129C5.97556 14.175 6.55889 13.0028 7.03889 11.8046L7.1 11.9216C7.16667 12.0566 7.23556 12.1916 7.30444 12.3266C7.82667 13.3571 8.36778 14.4214 8.47111 15.4991C8.53444 16.1764 8.26444 16.3913 8.17445 16.4621C7.71889 16.8221 6.70778 16.8435 5.71222 16.5139C5.57924 16.4695 5.43609 16.4669 5.30162 16.5064C5.16715 16.546 5.04767 16.6259 4.95889 16.7355C4.87133 16.8441 4.81936 16.9777 4.8102 17.1176C4.80104 17.2575 4.83515 17.3969 4.90778 17.5163C5.63 18.6997 6.97444 19.1677 8.27222 19.1677C8.76111 19.1677 9.24333 19.1014 9.68333 18.9821C10.51 18.7571 11.3322 18.3622 12.1011 17.8301H12.1033C12.4105 18.063 12.7477 18.2523 13.1056 18.3926V18.3938ZM10 0C15.5222 0 20 3.49537 20 10.2487C20 10.8934 19.9089 11.5673 19.7444 12.2591C19.2233 14.1401 17.2956 16.5578 15.3222 17.1461C15.0599 17.2262 14.7883 17.2705 14.5144 17.2778C14.2898 17.283 14.0654 17.2569 13.8478 17.2001C13.6313 17.1424 13.4235 17.0554 13.23 16.9414L13.2122 16.9301C13.42 16.7355 13.6211 16.5296 13.8144 16.3136L13.8678 16.2551C14.9367 15.0626 16.2678 13.5776 16.05 11.6764C15.9544 10.8371 15.5111 10.1014 14.8644 9.70537C14.2844 9.34987 13.5922 9.29138 12.9133 9.54113C11.6067 10.0215 10.8056 11.3715 10.4911 12.4751C10.0611 13.9894 10.3244 15.6442 11.1378 16.8289C10.5778 17.2 9.96466 17.4815 9.32 17.6636C9.09778 17.7232 8.86556 17.7649 8.62889 17.7874C8.77111 17.7154 8.90445 17.6299 9.02889 17.532C9.46 17.1911 9.94889 16.5409 9.83778 15.372C9.71111 14.0355 9.08333 12.8003 8.53 11.7101L8.33 11.313C8.29087 11.2375 8.25086 11.1625 8.21 11.088C7.98778 10.6684 7.81 10.3151 7.67111 10.017L7.72667 9.86737C7.93778 9.30937 8.29 8.37337 7.66 7.70625C7.52713 7.56253 7.35976 7.4561 7.17419 7.39735C6.98862 7.3386 6.79118 7.32952 6.60111 7.371C6.44788 7.40464 6.30451 7.47403 6.18241 7.57363C6.06031 7.67323 5.96285 7.80031 5.89778 7.94475C5.68667 8.40825 5.77 9.0585 6.20333 10.0935C5.11 13.4179 3.13444 16.47 2.00222 16.5566C0.825556 14.3955 0 12.1882 0 10.2487C0 3.49537 4.47778 0 10 0Z" fill="#FF4816"/>
</svg>
</span>
</div>
Related
I have a logo I created using a div and two letters which I want to move inside the coral colored div. However every time I change left/right properties or margin/padding I end up changing the letter placement in the design.
I tried playing around with the CSS using developer tools but I'm still having trouble.
Is there a better way I could use to move the logo itself and maybe make it a big smaller inside the coral div? This is what I'm trying to do screenshot. *note: screenshot is from Figma but I'm trying to code what it looks like
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<!-- Faustina-->
<link href='https://fonts.googleapis.com/css?family=Faustina' rel='stylesheet'>
<!-- Didact Gothic -->
<link href='https://fonts.googleapis.com/css?family=Didact Gothic' rel='stylesheet'>
<!-- Encode Sans Semi Condensed -->
<link href='https://fonts.googleapis.com/css?family=Encode Sans Semi Condensed' rel='stylesheet'>
<!-- Stylesheet -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="parent">
<!-- Description -->
<div class="description">
<div class="d">DESCRIPTION</div>
</div>
<!-- Logo -->
<div class="logo">
<div class="logo-container">
<div class="box">
<div class="letter-c">C</div>
<div class="letter-p">P</div>
</div>
</div>
</div>
<!-- Navigation -->
<div class="tabs">
<nav>
<ul>
<li>About</li>
<li>Projects</li>
<li>Blog</li>
<li>Resume</li>
</ul>
</nav>
</div>
<!-- Icon -->
<div class="icon"> </div>
<!-- Contact-Footer -->
<div class="contact">
<footer>
<div class="icon-container"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="linkedin-icon">
<!--! Font Awesome Pro 6.1.1 by #fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z" /></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512" class="github-icon">
<!--! Font Awesome Pro 6.1.1 by #fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z" /></svg>
</div>
</footer>
</div>
</body>
</html>
CSS
.parent {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: repeat(5, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
}
/****************************************************************/
/* Logo */
.logo {
grid-area: 1 / 1 / 2 / 2;
background-color: lightcoral;
}
.logo-container {
margin: 20px;
width: 100px;
height: 100px;
left: 100px;
top: 56px;
}
.letter-c {
position: absolute;
width: 31px;
height: 63px;
left: 26px;
top: 8px;
font-family: 'Faustina';
font-style: normal;
font-weight: 400;
font-size: 50px;
line-height: 63px;
/* identical to box height */
color: #DEC3C3;
-webkit-text-stroke: 2px white;
}
.letter-p {
position: absolute;
width: 27px;
height: 66px;
left: 47px;
top: 29px;
font-family: 'Didact Gothic';
font-style: normal;
font-weight: 400;
font-size: 50px;
line-height: 66px;
/* identical to box height */
color: #FFFFFF;
}
.box {
position: absolute;
width: 100px;
height: 100px;
left: 0px;
top: 0px;
background: #DEC3C3;
}
/****************************************************************/
/* Navigation */
.tabs {
grid-area: 1 / 2 / 2 / 6;
background-color: lightgreen;
}
ul {
list-style: none;
text-align: right;
margin: 20px;
}
li {
display: inline-block;
padding: 0px 10px;
font-family: 'Encode Sans Semi Condensed';
font-style: normal;
font-weight: 500;
font-size: 18px;
color: black;
}
/****************************************************************/
/* Description */
.description {
grid-area: 2 / 1 / 5 / 3;
background-color: red;
}
/****************************************************************/
/* Icon */
.icon {
grid-area: 2 / 3 / 5 / 6;
background-color: lightblue;
}
/****************************************************************/
/* Contact-Footer */
.contact {
grid-area: 5 / 1 / 6 / 6;
background-color: lightseagreen;
}
svg {
position: absolute;
width: 32px;
height: 32px;
color: #DEC3C3;
}
footer {
position: absolute;
width: 200px;
height: 50px;
left: 620px;
top: 942px;
}
.icon-container {
position: absolute;
width: 200px;
height: 50px;
left: 0px;
bottom: 0px;
background: rgba(222, 195, 195, 0.2);
border-radius: 30px;
}
.github-icon {
left: 132px;
bottom: 10px;
}
.linkedin-icon {
left: 42px;
bottom: 10px;
}
Make the following changes to .logo-container {...}:
Inside .logo-container {...}, include position: relative (to make absolute postioning of .box with respect to it, work). Then remove the margin, left and right values.
The margin property isn't necessary in .logo-container since it will cue its margins from the grid placement of its parent .logo.
The left and right properties aren't needed as well for the same reason as above (and also since, setting position: relative produces defaults of top: 0 and left: 0); remember, you are trying to position the .box div which houses the letters, not .logo-container itself. You should rather position .box from its own rule set.
If you need padding around .logo-container set it within its parent: .logo
Here's what .logo-container rule should look like:
.logo-container {
position: relative;
width: 100px;
height: 100px;
}
.box {
// Position me (w/ margin, left and right) from here instead
// if you wish to.
}
.logo {
...
// put padding around .logo-container here.
}
And Voilà! Problem fixed!
If you want the .parent div to take the full height of the viewport (i.e screen), you may set height: 100vh in its CSS rule:
.parent {
...
height: 100vh;
}
Alternatively (much better way):
html,
body {
height: 100%;
}
.parent {
height: 100%;
}
If you need to remove browser default box-sizing, margin and padding properties, then add this rule set at the top of your CSS file or section:
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
I cannot make the inside div to get the whole available space. The idea is to have a "tile" at the middle of the screen and all the content inside, taking all available space minus the padding, no matter the size of the screen, scrolled if necessary. The title is displayed vertically at the side of the tile. I cannot make it work - either the content is small and does not take all available space or takes to much space and does not scroll on small screen but overflow the tile. Adding "overflow: scroll" to the "wrapper" class hides the title. I am going in rounds.
<div class="block block_tile">
<section>
<div class="wrapper">
<h3 class="title">My Service</h3>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Pro 6.0.0 by #fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M575.8 255.5C575.8 273.5 560.8 287.6 543.8 287.6H511.8L512.5 447.7C512.5 450.5 512.3 453.1 512 455.8V472C512 494.1 494.1 512 472 512H456C454.9 512 453.8 511.1 452.7 511.9C451.3 511.1 449.9 512 448.5 512H392C369.9 512 352 494.1 352 472V384C352 366.3 337.7 352 320 352H256C238.3 352 224 366.3 224 384V472C224 494.1 206.1 512 184 512H128.1C126.6 512 125.1 511.9 123.6 511.8C122.4 511.9 121.2 512 120 512H104C81.91 512 64 494.1 64 472V360C64 359.1 64.03 358.1 64.09 357.2V287.6H32.05C14.02 287.6 0 273.5 0 255.5C0 246.5 3.004 238.5 10.01 231.5L266.4 8.016C273.4 1.002 281.4 0 288.4 0C295.4 0 303.4 2.004 309.5 7.014L564.8 231.5C572.8 238.5 576.9 246.5 575.8 255.5L575.8 255.5z"/></svg>
<div class="content">
<h1>Welcome to Our page. Please log in.</h1>
<button type="submit" name="_continue" class="btn btn-primary">Login</button>
<p>
You can register here.
</p>
</div>
</div>
</section>
</div>
css:
.wrapper {
display: flex;
flex-direction: column;
background-color: $white;
margin: auto;
min-width: 72rem;
max-height: 85vh;
width: 72rem;
min-height: 60rem;
position: absolute;
top: 20%;
border: 4px solid $primary;
padding: 6rem 8rem 6rem 8rem;
color: $dark;
font-size: small;
.content {
display: flex;
flex-direction: column;
justify-content: space-around;
max-height: 100%;
overflow: scroll;
overflow-x: hidden;
h1+p {
margin-top: -2.5rem;
margin-bottom: 5rem;
}
&::-webkit-scrollbar {
display: none;
}
h2 {
margin-bottom: 2rem;
font-style: normal;
font-weight: normal;
font-size: 1.6rem;
line-height: 3rem;
text-align: justify;
}
}
.title {
font-weight: 600;
font-size: 2.5rem;
line-height: 3.8rem;
color: $white;
position: absolute;
bottom: -.5rem;
left: 0;
transform: rotate(270deg);
transform-origin: 0 4rem;
}
This question already has answers here:
Position absolute but relative to parent
(5 answers)
Closed 2 years ago.
I have a problem with HTML/CSS. I'm trying to finish a challenge but i can't keep SVGs images in my div.
I will post screenshots of the attempted result then what i got.enter image description here
And here my code : `
html {
font-family: 'Poppins', sans-serif;
font-weight: 200;
background: hsl(0, 0%, 98%);
}
body {
display: flex;
flex-direction: column;
align-items: center;
}
header {
width: 40%;
text-align: center;
}
header h1 {
font-weight: 200;
}
header strong {
font-weight: bold;
}
main {
height: 80vh;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.card {
position: static;
display: flex;
flex-direction: column;
background: white;
border-radius: 9px;
box-shadow: 8px 1px 20px grey;
padding-left: 40px;
padding-right: 40px;
margin: 20px;
}
.card:nth-child(1) {
border-top: 5px solid hsl(180, 62%, 55%);
position: relative;
top: 50%;
}
.card:nth-child(2) {
border-top: 5px solid hsl(0, 78%, 62%);
}
.card:nth-child(3){
border-top: 5px solid hsl(212, 86%, 64%);
position: relative;
top: 50%;
}
.card:nth-child(4) {
border-top: 5px solid hsl(34, 97%, 64%);
grid-column: 2;
}
.card svg {
position: absolute;
bottom: 10%;
right: 10%;
}
#media screen and (max-width:360px) {
html {
font-size: 12px;
}
header {
width: 100%;
margin-bottom: 10%;
}
main {
height: auto;
display: block;
}
.card {
height: 200px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght#0,200;0,400;0,600;1,200;1,400;1,600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>Frontend Mentor | Four card feature section</title>
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
</head>
<body>
<header>
<h1>
Reliable, efficient delivery<br/>
<strong>Powered by Technology</strong>
</h1>
Our Artificial Intelligence powered tools use millions of project data points
to ensure that your project is successful
</header>
<main>
<div class="card">
<h2>Supervisor</h2>
Monitors activity to identify project roadblocks
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><g fill="none"><path fill="#676E74" d="M56.842 7.158c-9.526-9.563-24.902-9.525-34.428 0-8.025 8.026-9.45 20.44-3.525 30.003l-2.513 2.55-1.356 6.144 4.214 4.214 5.093-2.408 2.512-2.55a24.254 24.254 0 0030.003-3.525c9.563-9.526 9.525-24.902 0-34.428z"/><path fill="#474F54" d="M24.327 47.661l2.512-2.55a24.254 24.254 0 0030.003-3.525c9.563-9.526 9.525-24.902 0-34.428l-40.26 40.26 2.652 2.651 5.093-2.408z"/><path fill="#64E1DC" d="M54.213 9.787a20.56 20.56 0 00-14.585-6.041C28.236 3.746 19 12.98 19 24.372a20.564 20.564 0 006.041 14.586 20.564 20.564 0 0014.586 6.04c11.392 0 20.626-9.234 20.626-20.626a20.56 20.56 0 00-6.041-14.585z"/><path fill="#00C8C8" d="M60.254 24.372a20.56 20.56 0 00-6.041-14.585l-29.17 29.17A20.564 20.564 0 0039.627 45c11.392 0 20.626-9.235 20.626-20.627z"/><path fill="#EFEFF4" d="M56.239 23.41c-.184-.307-2.98-4.914-7.281-8.368-2.63-2.113-5.822-3.796-9.33-3.796-9.242 0-16.314 11.669-16.61 12.165l-.576.961.575.961c.184.309 2.98 4.916 7.28 8.37 2.631 2.112 5.823 3.795 9.33 3.795 9.243 0 16.315-11.668 16.612-12.165l.574-.96-.574-.962z"/><path fill="#DADAE5" d="M56.239 25.333l.574-.96-.574-.962c-.184-.308-2.98-4.915-7.281-8.369l-18.66 18.66c2.63 2.113 5.822 3.796 9.33 3.796 9.242 0 16.314-11.668 16.61-12.165z"/><path fill="#64E1DC" d="M43.604 20.396a5.607 5.607 0 00-3.976-1.65 5.632 5.632 0 00-5.626 5.626c0 1.551.631 2.958 1.65 3.976a5.609 5.609 0 003.976 1.65 5.632 5.632 0 005.625-5.626c0-1.55-.63-2.957-1.649-3.976z"/><path fill="#00C8C8" d="M45.253 24.372c0-1.55-.63-2.957-1.649-3.976l-7.952 7.952a5.608 5.608 0 003.976 1.65 5.632 5.632 0 005.625-5.626z"/><path fill="#676E74" d="M40.954 23.046a1.876 1.876 0 10-1.326 3.2 1.876 1.876 0 001.326-3.2z"/><path fill="#474F54" d="M41.503 24.372c0-.517-.21-.986-.55-1.326l-2.65 2.652a1.876 1.876 0 003.2-1.326z"/><path fill="#575C60" d="M20.333 43.667l-3.957-3.957L0 56.049l3.975 3.976L7.951 64l16.376-16.339z"/><path fill="#333637" d="M24.327 47.661l-3.994-3.994L3.975 60.025 7.951 64z"/></g></svg>
</div>
<div class="card">
<h2>Team Builder</h2>
Scans our talent network to create the optimal team for your project
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><g fill="none"><path fill="#EFEFF4" d="M64 14.454v41.788H0V14.454l3.75-3.787h56.5z"/><path fill="#DADAE5" d="M64 14.454v41.788H32V10.667h28.25z"/><path fill="#474F54" d="M0 0h64v15.515H0z"/><path fill="#32393F" d="M32 0h32v15.515H32z"/><g fill="#FF637B"><path d="M7.758 5.818h3.685v3.879H7.758zM15.128 5.818h3.685v3.879h-3.685zM22.497 5.818h3.685v3.879h-3.685z"/></g><path fill="#FF637B" d="M45.576 42.245V64H34.355v-3.71h-3.74V64H19.394V42.245l11.37-9.275h3.105z"/><path fill="#DADAE5" d="M11.636 22.303h41.697v3.879H11.636z"/><path fill="#C9C9D3" d="M32 22.303h20.364v3.879H32z"/><path fill="#E63950" d="M45.576 42.245V64H33.939v-3.71H32V32.97h1.435z"/><path fill="#EFEFF4" d="M30.061 45.576h3.878v3.879h-3.878z"/><path fill="#DADAE5" d="M32 45.576h1.939v3.879H32z"/><path fill="#676E74" d="M50.424 45.779l-2.452 2.706-15.487-13.526-15.488 13.526-2.452-2.706 17.94-15.718z"/><path fill="#474F54" d="M32 30.061l18.424 15.718-2.518 2.706L32 34.959z"/></g></svg>
</div>
<div class="card">
<h2>Calculator</h2>
Uses data from past projects to provide better delivery estimates
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><g fill="none"><path fill="#474F54" d="M64 0v41.25l-3.75 3.875H3.75L0 41.25V0z"/><path fill="#32393F" d="M64 0v41.25l-3.75 3.875H32V0z"/><path fill="#DADAE5" d="M22.625 50.875h18.75v11.25h-18.75z"/><path fill="#C9C9D3" d="M32 50.875h9.375v11.25H32z"/><path fill="#EFEFF4" d="M0 41.25h64v11.5H0z"/><path fill="#DADAE5" d="M32 41.25h32v11.5H32z"/><path fill="#EFEFF4" d="M15.125 60.25h33.75V64h-33.75z"/><path fill="#DADAE5" d="M32 60.25h16.875V64H32z"/><path fill="#549EF2" d="M20.75 7.5c-7.236 0-13.125 5.889-13.125 13.125S13.514 33.75 20.75 33.75s13.125-5.889 13.125-13.125S27.986 7.5 20.75 7.5zm0 18.75a5.631 5.631 0 01-5.625-5.625A5.631 5.631 0 0120.75 15a5.631 5.631 0 015.625 5.625 5.631 5.631 0 01-5.625 5.625z"/><g fill="#377FD2"><path d="M45.125 7.5H56.5v3.75H45.125zM37.625 7.5h3.75v3.75h-3.75zM45.125 22.5H56.5v3.75H45.125zM37.625 22.5h3.75v3.75h-3.75zM37.625 15H56.5v3.75H37.625zM37.625 30H56.5v3.75H37.625z"/></g></g></svg>
</div>
<div class="card">
<h2>Karma</h2>
Regularly evaluates our talent to ensure quality
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><g fill="none"><path fill="#676E74" d="M26.375 52.625h11.25V64h-11.25z"/><path fill="#333637" d="M32 52.625h5.625V64H32z"/><path fill="#4C545A" d="M22.625 47h18.75v9.375h-18.75z"/><path fill="#52585C" d="M32 47h9.375v9.375H32z"/><path fill="#FFDA2D" d="M45.012 36.725c-2.325 1.913-3.637 4.612-3.637 7.425V47h-18.75v-2.85c0-2.85-1.238-5.512-3.3-7.125-5.062-3.938-7.95-9.862-7.95-16.275a20.585 20.585 0 017.613-16.013C22.7 1.737 27.238 0 32 0c1.462 0 2.962.15 4.425.45 8.1 1.688 14.475 8.45 15.9 16.663 1.275 7.5-1.425 14.85-7.313 19.612z"/><path fill="#FDBF00" d="M45.012 36.725c-2.325 1.913-3.637 4.612-3.637 7.425V47H32V0c1.462 0 2.962.15 4.425.45 8.1 1.688 14.475 8.45 15.9 16.663 1.275 7.5-1.425 14.85-7.313 19.612z"/><path fill="#676E74" d="M18.875 45.125h26.25v3.75h-26.25z"/><path fill="#FF9100" d="M39.956 10.143l2.651 2.651-3.979 3.978-2.651-2.651z"/><path fill="#FDBF00" d="M25.372 24.727l2.651 2.651-3.979 3.979-2.651-2.651zM30.125 28.25h3.75v5.625h-3.75z"/><path fill="#FF9100" d="M38.628 24.727l3.979 3.979-2.651 2.651-3.979-3.979zM39.5 18.875h5.625v3.75H39.5z"/><path fill="#FDBF00" d="M24.044 10.143l3.979 3.979-2.651 2.65-3.979-3.978zM18.875 18.875H24.5v3.75h-5.625zM30.125 7.625h3.75v5.625h-3.75z"/><g fill="#FFDA2D"><path d="M0 18.875h7.625v3.75H0zM6.585 14.81l-5.75-3.75 2.08-3.12 5.75 3.75zM2.915 33.56l-2.08-3.12 5.75-3.75 2.08 3.12z"/></g><path fill="#FDBF00" d="M56.375 18.875H64v3.75h-7.625zM61.085 33.56l-5.75-3.75 2.08-3.12 5.75 3.75zM57.415 14.81l-2.08-3.12 5.75-3.75 2.08 3.12z"/><path fill="#FF9100" d="M32 7.625h1.875v5.625H32zM32 28.25h1.875v5.625H32z"/><path fill="#333637" d="M32 45.125h13.125v3.75H32z"/><path fill="#FDBF00" d="M32 11.375c-5.175 0-9.375 4.2-9.375 9.375s4.2 9.375 9.375 9.375 9.375-4.2 9.375-9.375-4.2-9.375-9.375-9.375z"/><path fill="#FF9100" d="M32 30.125v-18.75c5.175 0 9.375 4.2 9.375 9.375s-4.2 9.375-9.375 9.375z"/><path fill="#FFDA2D" d="M30.125 18.875h3.75v3.75h-3.75z"/><path fill="#FDBF00" d="M32 18.875h1.875v3.75H32z"/></g></svg>
</div>
</main>
<footer>
<p class="attribution">
Challenge by Frontend Mentor.
Coded by Romain Desson.
</p>
</footer>
</body>
</html>
`
It looks like SVGs from card 2 and 4 are not recognized as a part of the card because they are placed at the position I want but as a child of the main and not the div.
Thanks in advance.
Try changing position:static to position: relative in .card class
.card {
position: relative;
display: flex;
flex-direction: column;
background: white;
border-radius: 9px;
box-shadow: 8px 1px 20px grey;
padding-left: 40px;
padding-right: 40px;
margin: 20px;
}
I have this situation where the mouse hover shows the complete text but it's jumping on hover.
DEMO: https://jsfiddle.net/xeongtha/
img {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
}
.modal__grey--name {
width: 105px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
line-height: 1.1;
}
.modal__grey--name:hover {
overflow: inherit;
}
<label class="checkbox">
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E %3Cg fill='none' fill-rule='evenodd'%3E %3Ccircle cx='50' cy='50' r='50' fill='%23F8F8F8'/%3E %3Cpath fill='%23DDD' fill-rule='nonzero' d='M100 50c0-27.57-22.43-50-50-50S0 22.43 0 50c0 14.562 6.262 27.687 16.23 36.833l-.048.042 1.622 1.367c.105.089.22.162.325.249.862.714 1.755 1.393 2.664 2.049.294.213.589.425.889.633.97.669 1.967 1.303 2.985 1.905.222.131.446.258.67.386 1.114.634 2.252 1.232 3.418 1.781.085.04.172.077.258.117 3.798 1.765 7.852 3.062 12.092 3.827l.335.06c1.316.227 2.647.41 3.995.531.163.015.327.024.492.038 1.342.111 2.698.182 4.073.182 1.362 0 2.705-.07 4.04-.178.17-.015.338-.024.507-.038 1.337-.122 2.657-.299 3.96-.522.113-.02.228-.04.34-.062 4.177-.75 8.173-2.016 11.922-3.736.138-.064.278-.124.416-.19 1.122-.527 2.219-1.096 3.293-1.701.267-.151.533-.304.798-.46.979-.577 1.94-1.178 2.875-1.818.336-.23.665-.471.998-.711.798-.575 1.582-1.168 2.344-1.788.169-.136.35-.254.516-.394l1.664-1.39-.05-.041C93.679 77.82 100 64.636 100 50zM3.636 50C3.636 24.435 24.435 3.636 50 3.636c25.565 0 46.364 20.799 46.364 46.364 0 13.776-6.046 26.162-15.617 34.66-.534-.37-1.072-.7-1.623-.976l-15.395-7.697c-1.382-.69-2.24-2.08-2.24-3.623v-5.377c.356-.44.733-.938 1.122-1.485 1.993-2.815 3.59-5.946 4.756-9.315 2.304-1.094 3.791-3.389 3.791-5.98v-6.445c0-1.577-.578-3.106-1.613-4.307v-8.486c.095-.944.43-6.269-3.423-10.662-3.351-3.825-8.775-5.762-16.122-5.762-7.347 0-12.77 1.937-16.122 5.76-3.853 4.393-3.518 9.719-3.423 10.662v8.486c-1.033 1.202-1.613 2.73-1.613 4.307v6.445c0 2.002.898 3.87 2.436 5.13 1.473 5.769 4.504 10.136 5.624 11.616v5.262c0 1.483-.81 2.847-2.113 3.56l-14.376 7.842c-.458.249-.913.54-1.368.865C9.593 75.985 3.636 63.676 3.636 50zm73.562 37.513c-.636.462-1.283.909-1.94 1.336-.302.196-.602.393-.909.584-.858.53-1.73 1.036-2.622 1.509-.196.103-.394.202-.592.303-2.048 1.05-4.166 1.951-6.342 2.684-.077.026-.153.053-.231.078-1.14.378-2.295.715-3.462 1.004l-.01.002c-1.18.29-2.372.532-3.572.73l-.098.019c-1.13.183-2.267.316-3.41.416-.2.018-.403.031-.606.046-1.13.085-2.264.14-3.404.14-1.153 0-2.302-.057-3.445-.142-.199-.015-.397-.027-.593-.046-1.153-.101-2.3-.238-3.437-.423l-.152-.028c-2.404-.401-4.77-.992-7.073-1.765-.07-.024-.144-.05-.215-.073-1.143-.389-2.274-.82-3.385-1.296l-.024-.011c-1.05-.453-2.081-.955-3.1-1.484-.132-.069-.267-.134-.398-.205-.929-.496-1.838-1.033-2.734-1.593-.266-.167-.53-.336-.791-.507-.826-.54-1.64-1.102-2.433-1.696-.082-.062-.16-.128-.242-.19l.175-.098 14.376-7.842c2.473-1.349 4.01-3.936 4.01-6.752l-.003-6.55-.418-.505c-.04-.045-3.97-4.827-5.456-11.302l-.166-.72-.62-.401c-.874-.566-1.398-1.511-1.398-2.531v-6.446c0-.845.358-1.633 1.013-2.223l.6-.542V30.865l-.016-.238c-.006-.043-.542-4.416 2.538-7.927 2.629-2.996 7.134-4.518 13.387-4.518 6.23 0 10.72 1.509 13.356 4.483 3.077 3.475 2.573 7.93 2.57 7.966l-.017 10.365.6.542c.653.59 1.013 1.378 1.013 2.224v6.445c0 1.297-.882 2.473-2.147 2.864l-.904.278-.291.9c-1.073 3.333-2.6 6.411-4.538 9.15-.477.672-.94 1.268-1.338 1.725l-.451.514v6.726c0 2.93 1.629 5.567 4.25 6.876l15.395 7.696c.098.05.195.1.291.151-.194.148-.394.284-.59.426z'/%3E %3C/g%3E %3C/svg%3E" class="dropdown__static--profile">
<span class="modal__grey--name">This is a long text that needs to be cut</span>
<span class="checkmark" style="padding-left: 4px;"></span>
</label>
You can make your label a flexbox and it won't jump anymore:
label {
display: flex;
}
Try this. Remove line-height: 1.1; and add vertical-align: middle;
img {
width: 24px;
height: 24px;
border-radius: 50%;
object-fit: cover;
}
.modal__grey--name {
width: 105px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
vertical-align: middle;
}
.modal__grey--name:hover {
overflow: inherit;
}
https://jsfiddle.net/h7mfagb9/7/
I have the following design:
and each time I hover an attachment, I have the ability to delete it:
Sometimes, when having many attachments and I hover an attachment the row is too long and the last attachment in the row jumps to the next row.
I tried to google it and found the usage of (nth-last(4n)) but I don't know how many items i have in each row.
I thought about something like this:
last-child-in-a-row { margin-right: 10px; }
So, in that case i will have enough space for the growing x element.
Is there any suggested workaround/best-practice for this?
EDIT:
HTML (rendered from React):
<div class="attachmentHolder">
<button class="attachmentButton">
<svg class="leftAttachment" ... />
<a ...> some text </a>
<svg class="attachmentClose" ... />
</button>
<button class="attachmentButton">
<svg class="leftAttachment" ... />
<a ...> some text 2 </a>
<svg class="attachmentClose" ... />
</button>
...
...
</div>
CSS:
.attachmentHolder {
display: flex;
flex-wrap: wrap;
}
.attachmentButton {
padding-right: 0;
padding-left: 6px;
margin: 0 8px 10px 0;
.attachmentClose {
max-width: 0;
transition: max-width .1s ease-out, margin-left .1s ease-out;
}
&:hover {
.attachmentClose {
max-width: 25px;
margin-left: 8px;
margin-right: 8px;
fill: $secondary;
}
}
}
.leftAttachment {
height: 20px;
width: 15px;
margin: 0 4px 3px 0;
}