I am having two issues with the following styled link.
There is a small, white border being displayed on the left and right sides of link on hover.
The ::before border radius is being applied during the transition on Webkit browsers. All other browsers are applying it before the transition.
I have tried adjusting z indexes for various elements, but this has had no effect on the small, white border issue.
I have tried applying border radius to a::before and a:hover::before to see if that would fix the issue in Webkit browsers, but no luck.
Any ideas on why these CSS issues are occurring?
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill::before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
background-color: #D61E15;
border: 0.03125rem solid #D61E15;
border-radius: 1.3125rem;
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-transition: transform 0.35s ease-in-out;
-moz-transition: transform 0.35s ease-in-out;
transition: transform 0.35s ease-in-out;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
.cta--pill:hover::before {
transform: translateX(0);
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>
You may also slide background-gradients via background-position.
possible example:
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-image: radial-gradient(circle at 75% 50%, #D61E15 1.3rem, transparent 1.35rem), linear-gradient(0, #D61E15, #D61E15);
background-repeat: no-repeat;
background-size: 200% 200%;
background-position: 180% 50%, 220% 0;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill:hover {
background-position: 50% 50%, 100% 0;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>
You can try adding a negative inset to the ::before selector.
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill::before {
content: "";
position: absolute;
top: -1px;
right: -1px;
bottom: -1px;
left: -1px;
z-index: 1;
background-color: #D61E15;
border: 0.03125rem solid #D61E15;
border-radius: 1.3125rem;
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-transition: transform 0.35s ease-in-out;
-moz-transition: transform 0.35s ease-in-out;
transition: transform 0.35s ease-in-out;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
.cta--pill:hover::before {
transform: translateX(0);
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>
Adding background-color: #D61E15; inside .cta--pill:hover will solve your white border problem.
body {
background-color: #1A1A1A;
padding: 3rem;
}
.cta {
display: inline-block;
text-decoration: none;
font-weight: 700;
font-size: 1.125rem;
font-family: "Barlow", sans-serif;
letter-spacing: -0.0225rem;
color: #D61E15;
}
.cta--pill {
padding: 0.625rem 1rem 0.625rem 1.5rem;
position: relative;
overflow: hidden;
background-color: #fff;
border: 0.03125rem solid #E6E6E6;
border-radius: 1.3125rem;
-webkit-transition: 0.3s ease-in-out;
-moz-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.cta--pill::before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
background-color: #D61E15;
border: 0.03125rem solid #D61E15;
border-radius: 1.3125rem;
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-transition: transform 0.35s ease-in-out;
-moz-transition: transform 0.35s ease-in-out;
transition: transform 0.35s ease-in-out;
}
.cta--pill .cta-text {
padding-right: 2.25rem;
position: relative;
z-index: 2;
}
.cta--pill .cta-arrow {
display: flex;
justify-content: center;
align-items: center;
width: 1.75rem;
height: 1.75rem;
position: absolute;
top: 0.4375rem;
right: 0.5rem;
z-index: 2;
background-color: #D61E15;
box-shadow: 0 2px 5px 0 rgba(176, 25, 17, 0.41);
border-radius: 100%;
border: 0.03125rem solid transparent;
-webkit-transition: 0.4s ease-in-out;
-moz-transition: 0.4s ease-in-out;
transition: 0.4s ease-in-out;
}
.cta--pill:hover {
border-color: #D61E15;
background-color: #D61E15;
box-shadow: 0 4px 10px 0 rgba(176, 25, 17, 0.41);
color: #fff;
}
.cta--pill:hover::before {
transform: translateX(0);
}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#700&display=swap" rel="stylesheet">
<a class="cta cta--pill cta--no-shadow" href="#" title="View all services">
<span class="cta-text">All Services</span>
<span class="cta-arrow">
<svg role="img" class="arrow arrow--right" width="14" height="14" xmlns="http://www.w3.org/2000/svg">
<path d="M6.02 1.183l.658-.658a.708.708 0 0 1 1.004 0l5.761 5.758a.708.708 0 0 1 0 1.004l-5.76 5.761a.708.708 0 0 1-1.005 0l-.658-.658a.712.712 0 0 1 .012-1.016l3.57-3.402H1.087a.71.71 0 0 1-.711-.711v-.949a.71.71 0 0 1 .71-.711h8.518L6.032 2.199a.707.707 0 0 1-.012-1.016z" fill="#FFF"></path>
</svg>
</span>
</a>
Related
Hi I am trying to combine 2 hover effects. First hover effect takes places when you hover over the button, the other one is when you hover over the arrow. I am trying to combine those 2 hover effects to take place simultaneously. Could anyone please help me with that? Thank you so much
.btnMain {
padding: 15px 110px;
text-align: center;
transition: 0.5s;
background-size: 200% auto;
color: white;
box-shadow: 0 0 20px #eee;
border-radius: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing:1px;
margin-top:40px;
font-size:16px;
display: inline-block;
border: 2px;
font-family: "Raleway", sans-serif;
cursor: pointer;
moz-transition: all .4s ease-in-out;
}
.btnMain:hover {
background-position: 100% 0;
color:#fff;
moz-transition: all .4s ease-in-out;
-o-transition: all .4s ease-in-out;
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
.gradient {
background-image: linear-gradient(to right, #25aae1, #4481eb, #04befe, #3f86ed);
box-shadow: 0 4px 15px 0 rgb(65 132 234 / 75%);
}
.arrowIntro {
color: black;
font-size:60px;
margin-left:-2%;
}
.arrowIntro::before {
display: inline-block;
padding-left: -8px;
content: "🠒";
transition: transform 0.3s ease-out;
position: relative;
top: 16px;
left: 3px;
}
.arrowIntro:hover {
color: black;
}
.arrowIntro:hover::before {
transform: translateX(12px);
}
Contact me<a id="arrowIntroId" href="#kontakt" class="arrowIntro"></a>
Please refer to CSS Transform Modules. Also, a technicality: You were trying to move the arrow on .arrowIntro:hover while you wanted it to move on .btnMain:hover
.btnMain {
padding: 15px 110px;
text-align: center;
transition: 0.5s;
background-size: 200% auto;
color: white;
box-shadow: 0 0 20px #eee;
border-radius: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing:1px;
margin-top:40px;
font-size:16px;
display: inline-block;
border: 2px;
font-family: "Raleway", sans-serif;
cursor: pointer;
moz-transition: all .4s ease-in-out;
position: relative;
}
.btnMain:hover {
background-position: 100% 0;
color:#fff;
moz-transition: all .4s ease-in-out;
-o-transition: all .4s ease-in-out;
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
.gradient {
background-image: linear-gradient(to right, #25aae1, #4481eb, #04befe, #3f86ed);
box-shadow: 0 4px 15px 0 rgb(65 132 234 / 75%);
}
.arrowIntro {
margin-left:10px;
display:inline-block;
color: black;
position:absolute;
top:7px;
right:20px;
transition: transform 500ms ease-in-out 25ms;
}
.arrowIntro::before {
content: "→";
font-size:30px;
color: white;
}
.btnMain:hover .arrowIntro {
transform: translateX(12px);
color: red;
}
Contact me<div class="arrowIntro"></div>
You need to move the hover to the .btnMain element:
.btnMain:hover .arrowIntro {
color: black;
}
.btnMain:hover .arrowIntro::before {
transform: translateX(12px);
}
Also, you cannot have an a tag within another a tag. That's malformed HTML and the first a will close at the first closing a. I changed that to a span.
.btnMain {
padding: 15px 110px;
text-align: center;
transition: 0.5s;
background-size: 200% auto;
color: white;
box-shadow: 0 0 20px #eee;
border-radius: 10px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
margin-top: 40px;
font-size: 16px;
display: inline-block;
border: 2px;
font-family: "Raleway", sans-serif;
cursor: pointer;
-moz-transition: all .4s ease-in-out;
}
.btnMain:hover {
background-position: 100% 0;
color: #fff;
-moz-transition: all .4s ease-in-out;
-o-transition: all .4s ease-in-out;
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
.gradient {
background-image: linear-gradient(to right, #25aae1, #4481eb, #04befe, #3f86ed);
box-shadow: 0 4px 15px 0 rgb(65 132 234 / 75%);
}
.arrowIntro {
color: black;
margin-left: -2%;
}
.arrowIntro::before {
display: inline-block;
padding-left: -8px;
content: "🠒";
transition: transform 0.3s ease-out;
position: relative;
left: 4px;
}
.btnMain:hover .arrowIntro {
color: black;
}
.btnMain:hover .arrowIntro::before {
transform: translateX(12px);
}
Contact me<span id="arrowIntroId" class="arrowIntro"></span>
i have my link that was styled, but when I change link tag to button in html and css styling won't work. How can get that styling on button type submit note I can't get link to submit via js because of interference with stripe that's why i wanna get this one working
a styling that is working
a.animated-button:link:after, a.animated-button:visited:after {
content: "";
position: absolute;
height: 0%;
left: 50%;
top: 0;
width: 150%;
z-index: -1;
-webkit-transition: all 0.75s ease 0s;
-moz-transition: all 0.75s ease 0s;
-o-transition: all 0.75s ease 0s;
transition: all 0.75s ease 0s;
}
a.animated-button:link:hover, a.animated-button:visited:hover {
color: #FFF;
text-shadow: none;
}
a.animated-button:link:hover:after, a.animated-button:visited:hover:after {
height: 450%;
}
a.animated-button:link, a.animated-button:visited {
position: relative;
display: block;
margin: 0px auto 0;
padding: 14px 15px;
color: #fff;
font-size:12px;
border-radius: 0;
font-weight: bold;
text-align: center;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
letter-spacing: .08em;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(0, 0, 0, 0.2);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
a.animated-button.thar-three {
color: rgb(68, 68, 68);
cursor: pointer;
display: block;
position: relative;
border: 1px solid #dddddd;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
a.animated-button.thar-three:hover {
color: #000 !important;
background-color: transparent;
text-shadow: nthree;
}
a.animated-button.thar-three:hover:before {
left: 0%;
right: auto;
width: 100%;
}
a.animated-button.thar-three:before {
display: block;
position: absolute;
top: 0px;
right: 0px;
height: 100%;
width: 0px;
z-index: -1;
content: '';
color: #000 !important;
background: #f5f5f5;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
{% trans "pay" %}
button styling that won't work
button[type=submit].animated-button:link:after, button[type=submit].animated-button:visited:after {
content: "";
position: absolute;
height: 0%;
left: 50%;
top: 0;
width: 150%;
z-index: -1;
-webkit-transition: all 0.75s ease 0s;
-moz-transition: all 0.75s ease 0s;
-o-transition: all 0.75s ease 0s;
transition: all 0.75s ease 0s;
}
button[type=submit].animated-button:link:hover, button[type=submit].animated-button:visited:hover {
color: #FFF;
text-shadow: none;
}
button[type=submit].animated-button:link:hover:after, button[type=submit].animated-button:visited:hover:after {
height: 450%;
}
button[type=submit].animated-button:link, button[type=submit].animated-button:visited {
position: relative;
display: block;
margin: 0px auto 0;
padding: 14px 15px;
color: #fff;
font-size:12px;
border-radius: 0;
font-weight: bold;
text-align: center;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
letter-spacing: .08em;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(0, 0, 0, 0.2);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
button[type=submit].animated-button.thar-three {
color: rgb(68, 68, 68);
cursor: pointer;
display: block;
position: relative;
border: 1px solid #dddddd;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
button[type=submit].animated-button.thar-three:hover {
color: #000 !important;
background-color: transparent;
text-shadow: nthree;
}
button[type=submit].animated-button.thar-three:hover:before {
left: 0%;
right: auto;
width: 100%;
}
button[type=submit].animated-button.thar-three:before {
display: block;
position: absolute;
top: 0px;
right: 0px;
height: 100%;
width: 0px;
z-index: -1;
content: '';
color: #000 !important;
background: #f5f5f5;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
<button type="submit" href="" class="btn btn-sm animated-button thar-three">{% trans "pay" %}</button>
since a div is not a link, you can't use the selectors :link nor :visited. By simply removing them from your css, the result is way closer. Of course, you may have to implement a method to replace the use of :link and :visited
button[type=submit].animated-button:after, button[type=submit].animated-button:after {
content: "";
position: absolute;
height: 0%;
left: 50%;
top: 0;
width: 100%;
z-index: -1;
-webkit-transition: all 0.75s ease 0s;
-moz-transition: all 0.75s ease 0s;
-o-transition: all 0.75s ease 0s;
transition: all 0.75s ease 0s;
}
button[type=submit].animated-button:hover, button[type=submit].animated-button:hover {
color: #FFF;
text-shadow: none;
}
button[type=submit].animated-button:hover:after, button[type=submit].animated-button:hover:after {
height: 450%;
}
button[type=submit].animated-button, button[type=submit].animated-button {
position: relative;
display: block;
margin: 0px auto 0;
padding: 14px 15px;
color: #fff;
font-size:12px;
border-radius: 0;
font-weight: bold;
text-align: center;
text-decoration: none;
text-transform: uppercase;
overflow: hidden;
letter-spacing: .08em;
text-shadow: 0 0 1px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(0, 0, 0, 0.2);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
button[type=submit].animated-button.thar-three {
color: rgb(68, 68, 68);
cursor: pointer;
display: block;
position: relative;
border: 1px solid #dddddd;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
button[type=submit].animated-button.thar-three:hover {
color: #000 !important;
background-color: transparent;
text-shadow: nthree;
}
button[type=submit].animated-button.thar-three:hover:before {
left: 0%;
right: auto;
width: 100%;
}
button[type=submit].animated-button.thar-three:before {
display: block;
position: absolute;
top: 0px;
right: 0px;
height: 100%;
width: 0px;
z-index: -1;
content: '';
color: #000 !important;
background: #f5f5f5;
transition: all 0.4s cubic-bezier(0.42, 0, 0.58, 1);
}
<button type="submit" href="" class="btn btn-sm animated-button thar-three">{% trans "pay" %}</button>
Here's my HTML:
<div class="container">
<div class="column">
<div class="post-module">
<div class="thumbnail">
<div class="date">
<div class="day">27</div>
<div class="month">Mar</div>
</div><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/photo-1429043794791-eb8f26f44081.jpeg"/>
</div>
<div class="post-content">
<div class="category">Photos</div>
<h1 class="title">City Lights in New York</h1>
<h2 class="sub_title">The city that never sleeps.</h2>
<p class="description">New York, the largest city in the U.S., is an architectural marvel with plenty of historic monuments, magnificent buildings and countless dazzling skyscrapers.</p>
<div class="post-meta"><span class="timestamp"><i class="fa fa-clock-">o</i> 6 mins ago</span><span class="comments"><i class="fa fa-comments"></i> 39 comments</span></div>
</div>
</div>
<div class="post-module">
<!-- Thumbnail-->
<div class="thumbnail">
<div class="date">
<div class="day">27</div>
<div class="month">Mar</div>
</div><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/photo-1429043794791-eb8f26f44081.jpeg"/>
</div>
<!-- Post Content-->
<div class="post-content">
<div class="category">Photos</div>
<h1 class="title">City Lights in New York</h1>
<h2 class="sub_title">The city that never sleeps.</h2>
<p class="description">New York, the largest city in the U.S., is an architectural marvel with plenty of historic monuments, magnificent buildings and countless dazzling skyscrapers.</p>
<div class="post-meta"><span class="timestamp"><i class="fa fa-clock-">o</i> 6 mins ago</span><span class="comments"><i class="fa fa-comments"></i> 39 comments</span></div>
</div>
</div>
<div class="post-module">
<div class="thumbnail">
<div class="date">
<div class="day">27</div>
<div class="month">Mar</div>
</div><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/photo-1429043794791-eb8f26f44081.jpeg"/>
</div>
<div class="post-content">
<div class="category">Photos</div>
<h1 class="title">City Lights in New York</h1>
<h2 class="sub_title">The city that never sleeps.</h2>
<p class="description">New York, the largest city in the U.S., is an architectural marvel with plenty of historic monuments, magnificent buildings and countless dazzling skyscrapers.</p>
<div class="post-meta"><span class="timestamp"><i class="fa fa-clock-">o</i> 6 mins ago</span><span class="comments"><i class="fa fa-comments"></i> 39 comments</span></div>
</div>
</div>
</div>
</div>
And here's my CSS:
body {
background: #f2f2f2;
font-family: 'proxima-nova-soft', sans-serif;
font-size: 14px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.post-module {
position: relative;
z-index: 1;
display: block;
background: #FFFFFF;
min-width: 270px;
height: 470px;
-webkit-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
-webkit-transition: all 0.3s linear 0s;
-moz-transition: all 0.3s linear 0s;
-ms-transition: all 0.3s linear 0s;
-o-transition: all 0.3s linear 0s;
transition: all 0.3s linear 0s;
}
.post-module:hover,
.hover {
-webkit-box-shadow: 0px 1px 35px 0px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 1px 35px 0px rgba(0, 0, 0, 0.3);
box-shadow: 0px 1px 35px 0px rgba(0, 0, 0, 0.3);
}
.post-module:hover .thumbnail img,
.hover .thumbnail img {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
transform: scale(1.1);
opacity: 0.6;
}
.post-module .thumbnail {
background: #000000;
height: 400px;
overflow: hidden;
}
.post-module .thumbnail .date {
position: absolute;
top: 20px;
right: 20px;
z-index: 1;
background: #e74c3c;
width: 55px;
height: 55px;
padding: 12.5px 0;
-webkit-border-radius: 100%;
-moz-border-radius: 100%;
border-radius: 100%;
color: #FFFFFF;
font-weight: 700;
text-align: center;
-webkti-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.post-module .thumbnail .date .day {
font-size: 18px;
}
.post-module .thumbnail .date .month {
font-size: 12px;
text-transform: uppercase;
}
.post-module .thumbnail img {
display: block;
width: 120%;
-webkit-transition: all 0.3s linear 0s;
-moz-transition: all 0.3s linear 0s;
-ms-transition: all 0.3s linear 0s;
-o-transition: all 0.3s linear 0s;
transition: all 0.3s linear 0s;
}
.post-module .post-content {
position: absolute;
bottom: 0;
background: #FFFFFF;
width: 100%;
padding: 30px;
-webkti-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.3s cubic-bezier(0.37, 0.75, 0.61, 1.05) 0s;
-moz-transition: all 0.3s cubic-bezier(0.37, 0.75, 0.61, 1.05) 0s;
-ms-transition: all 0.3s cubic-bezier(0.37, 0.75, 0.61, 1.05) 0s;
-o-transition: all 0.3s cubic-bezier(0.37, 0.75, 0.61, 1.05) 0s;
transition: all 0.3s cubic-bezier(0.37, 0.75, 0.61, 1.05) 0s;
}
.post-module .post-content .category {
position: absolute;
top: -34px;
left: 0;
background: #e74c3c;
padding: 10px 15px;
color: #FFFFFF;
font-size: 14px;
font-weight: 600;
text-transform: uppercase;
}
.post-module .post-content .title {
margin: 0;
padding: 0 0 10px;
color: #333333;
font-size: 26px;
font-weight: 700;
}
.post-module .post-content .sub_title {
margin: 0;
padding: 0 0 20px;
color: #e74c3c;
font-size: 20px;
font-weight: 400;
}
.post-module .post-content .description {
display: none;
color: #666666;
font-size: 14px;
line-height: 1.8em;
}
.post-module .post-content .post-meta {
margin: 30px 0 0;
color: #999999;
}
.post-module .post-content .post-meta .timestamp {
margin: 0 16px 0 0;
}
.post-module .post-content .post-meta a {
color: #999999;
text-decoration: none;
}
.hover .post-content .description {
display: block !important;
height: auto !important;
opacity: 1 !important;
}
.container {
max-width: 50%;
min-width: 640px;
margin: 0 auto;
}
.container:before,
.container:after {
content: '';
display: block;
clear: both;
}
.container .column {
width: 50%;
padding: 0 25px;
-webkti-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
float: left;
}
.container .column .demo-title {
margin: 0 0 15px;
color: #666666;
font-size: 18px;
font-weight: bold;
text-transform: uppercase;
}
And my JavaScript:
$(window).load(function() {
$('.post-module').hover(function() {
$(this).find('.description').stop().animate({
height: "toggle",
opacity: "toggle"
}, 300);
});
});
This is the output I'm getting (my screen is too small to capture the rest of the first and bottom card):
my output
As you can see, all 3 cards are directly on top of each other.
I would like for them to be in the same row and next to each other. Like this:
my desired output
What am I doing wrong? I tried doing float:left; and display:inline and stuff but nothing works.
Here's a codepen.io if that helps: https://codepen.io/thatrandomthinglol/pen/QWKKbQd
Add property display: flex and justify-content: space-between to .column, now the cards should be next to each other, you can add margin: 0 (x)px to .post-module to give some gaps between the cards.
If you want to make the cards bigger, you should remove property width: 50% in .column or max-width: 50% in .container.
Here is an example of cards next to each other after adding the 3 properties. As said, you can make them bigger by removing the width constraints.
Float actually also works, but you need to add the property float-left to .post-module rather than .column (i.e. add to the cards). And you need to make sure that the total width of the 3 cards is smaller than the width of the column, only in this way will the floated elements be displayed in one row, next to each other. Otherwise, the cards simply don't have enough space in one row and will have to be put in separate rows.
I would not use flex. Try this. Change the width of post-module if you want other than 3 items per row.
.container .column {
padding: 0 25px;
text-align: left;
-webkti-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.post-module {
position: relative;
z-index: 1;
background: #FFFFFF;
width: 31%;
display: inline-block;
margin: 5px;
background: #FFFFFF;
height: 470px;
-webkit-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.15);
-webkit-transition: all 0.3s linear 0s;
-moz-transition: all 0.3s linear 0s;
-ms-transition: all 0.3s linear 0s;
-o-transition: all 0.3s linear 0s;
transition: all 0.3s linear 0s;
}
I've tried many approaches to get this working correctly, but with no success.. I notice that this question has been asked a few times already, and i've tried the solutions i've found.. but with no success..
So i'll upfront say sorry if someone of you find this question as a duplicate :(
The hovered element is "food-box", and the element which needs the scale-animation is "food-box-image" :
<div class="food-box">
<div class="food-box-image" style="background-image: url(myimage.jpg);"></div>
... and i'm trying to get the animation working like this :
.food-box:hover ~ .foox-box-image {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
border:8px solid red;
}
but it will not fire :
the only way i got it working, is with specifying .food-box-image:hover, but then it will not fire when hovering the needed div element..
Here's complete code (which runs) :
Anyone know how to do this ?
.fixedbuttons-container {
position: absolute;
width: 100%;
}
.buttons,
.fixedbuttons {
display: flex;
flex-flow: row wrap;
}
.fixedbuttons > * {
width: 25%;
}
.fixedbuttons > * > * {
width: 100%;
text-align: center;
}
.food-box-container {
padding: 10px;
}
.food-box {
flex: 1;
position: relative;
background-color: white;
min-height: 300px;
background-color: #ffffff;
-webkit-box-shadow: 0px 0px 20px 4px rgba(0, 0, 0, 0.35);
-moz-box-shadow: 0px 0px 20px 4px rgba(0, 0, 0, 0.35);
box-shadow: 0px 0px 20px 4px rgba(0, 0, 0, 0.35);
border-color: #666666;
border: 1px solid #666666;
word-wrap: break-word;
margin: 0 !important;
padding: 0 !important;
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
}
.food-box:hover {
cursor: pointer;
-webkit-box-shadow: 0px 0px 20px 4px rgba(255, 255, 255, 0.35);
-moz-box-shadow: 0px 0px 20px 4px rgba(255, 255, 255, 0.35);
box-shadow: 0px 0px 20px 4px rgba(255, 255, 255, 0.35);
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
}
.food-box:hover ~ .foox-box-image {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
border:8px solid red;
}
.food-box .food-box-image {
position: absolute top: 0 left: 0;
background-size: cover;
width: 100%;
min-height: 150px;
background-color: #ffffff;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.food-box .food-box-content {
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
position: absolute bottom: 0 left: 0;
word-wrap: break-word;
width: 100%;
min-height: 150px;
background-color: #ffd531;
color: #000000;
font-size: 80%;
padding-top: 60px;
padding-left: 5px;
padding-right: 5px;
}
.food-box:hover > .food-box .food-box-content {
background: yellow !important;
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
}
.food-box .food-box-badge {
display: table;
background: #ffffff !important;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 100px;
height: 100px;
line-height: 100px;
border-radius: 50%;
font-size: 12px;
color: #000000;
text-align: center;
-webkit-box-shadow: 0px 0px 39px 4px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 39px 4px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 39px 4px rgba(0, 0, 0, 0.75);
border-color: #d3e0e9;
border: 1px solid #b3c9e5;
padding-left: 10px;
padding-right: 10px;
}
.food-box .food-box-badge span {
color: #666;
display: table-cell;
vertical-align: middle;
line-height: 1.2em;
word-wrap: break-word;
}
<div class="fixedbuttons-container">
<div class="fixedbuttons">
<div>
<a>
<div class="food-box-container">
<div class="food-box">
<div class="food-box-image" style="background-image: url(https://assets.epicurious.com/photos/57c5c6d9cf9e9ad43de2d96e/master/pass/the-ultimate-hamburger.jpg);"></div>
<div class="food-box-badge"><span>Sydhavsmeny</span></div>
<div class="food-box-content">
adslkfjaølkfj
</div>
</div>
</div>
</a>
</div>
<div>
<a>
<div class="food-box-container">
<div class="food-box">
<div class="food-box-image scalable" style="background-image: url(https://assets.epicurious.com/photos/57c5c6d9cf9e9ad43de2d96e/master/pass/the-ultimate-hamburger.jpg);"></div>
<div class="food-box-badge"><span>Sydhavsmeny</span></div>
<div class="food-box-content">
adslkfjaølkfj
</div>
</div>
</div>
</a>
</div>
</div </div>
The first is the typo foox* to be replaced with .food-box:hover > .foox-box-image as pointed out by #panther
Now if you want to only scale within the container box apply overflow: hidden to the wrapping container which is food-box
Hope this is what you are expecting.
.fixedbuttons-container {
position: absolute;
width: 100%;
}
.buttons,
.fixedbuttons {
display: flex;
flex-flow: row wrap;
}
.fixedbuttons > * {
width: 25%;
}
.fixedbuttons > * > * {
width: 100%;
text-align: center;
}
.food-box-container {
padding: 10px;
}
.food-box {
overflow: hidden;
flex: 1;
position: relative;
background-color: white;
min-height: 300px;
background-color: #ffffff;
-webkit-box-shadow: 0px 0px 20px 4px rgba(0, 0, 0, 0.35);
-moz-box-shadow: 0px 0px 20px 4px rgba(0, 0, 0, 0.35);
box-shadow: 0px 0px 20px 4px rgba(0, 0, 0, 0.35);
border-color: #666666;
border: 1px solid #666666;
word-wrap: break-word;
margin: 0 !important;
padding: 0 !important;
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
}
.food-box:hover {
cursor: pointer;
-webkit-box-shadow: 0px 0px 20px 4px rgba(255, 255, 255, 0.35);
-moz-box-shadow: 0px 0px 20px 4px rgba(255, 255, 255, 0.35);
box-shadow: 0px 0px 20px 4px rgba(255, 255, 255, 0.35);
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
}
.food-box:hover > .food-box-image {
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
.food-box .food-box-image {
position: absolute top: 0 left: 0;
background-size: cover;
width: 100%;
min-height: 150px;
background-color: #ffffff;
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.food-box .food-box-content {
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
position: absolute bottom: 0 left: 0;
word-wrap: break-word;
width: 100%;
min-height: 150px;
background-color: #ffd531;
color: #000000;
font-size: 80%;
padding-top: 60px;
padding-left: 5px;
padding-right: 5px;
}
.food-box:hover > .food-box .food-box-content {
background: yellow !important;
-moz-transition: all .1s ease-in;
-o-transition: all .1s ease-in;
-webkit-transition: all .1s ease-in;
transition: all .1s ease-in;
}
.food-box .food-box-badge {
display: table;
background: #ffffff !important;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 100px;
height: 100px;
line-height: 100px;
border-radius: 50%;
font-size: 12px;
color: #000000;
text-align: center;
-webkit-box-shadow: 0px 0px 39px 4px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 39px 4px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 39px 4px rgba(0, 0, 0, 0.75);
border-color: #d3e0e9;
border: 1px solid #b3c9e5;
padding-left: 10px;
padding-right: 10px;
}
.food-box .food-box-badge span {
color: #666;
display: table-cell;
vertical-align: middle;
line-height: 1.2em;
word-wrap: break-word;
}
<div class="fixedbuttons-container">
<div class="fixedbuttons">
<div>
<a>
<div class="food-box-container">
<div class="food-box">
<div class="food-box-image" style="background-image: url(https://assets.epicurious.com/photos/57c5c6d9cf9e9ad43de2d96e/master/pass/the-ultimate-hamburger.jpg);"></div>
<div class="food-box-badge"><span>Sydhavsmeny</span></div>
<div class="food-box-content">
adslkfjaølkfj
</div>
</div>
</div>
</a>
</div>
<div>
<a>
<div class="food-box-container">
<div class="food-box">
<div class="food-box-image scalable" style="background-image: url(https://assets.epicurious.com/photos/57c5c6d9cf9e9ad43de2d96e/master/pass/the-ultimate-hamburger.jpg);"></div>
<div class="food-box-badge"><span>Sydhavsmeny</span></div>
<div class="food-box-content">
adslkfjaølkfj
</div>
</div>
</div>
</a>
</div>
</div </div>
I've been trying to create an image that on hover a caption will slide out from left to right on top and from left to right on bottom. I've gotten it working on two seperate images ie: one image has the top caption and one image has the bottom caption; however I can't seem to get both working on one image. Also I'm trying to get the captions and image to scale to the container which is boggling me. Another thing I was trying is to insert two divs into the top slide caption and get them to scale to the size but I couldn't get it going.
Here's my code at the moment:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>slide caption thingy</title>
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
<div class="wrapper">
<header>
<h1 class="main_head">hj</h1>
</header>
<hr />
<div class="container left">
<img src="images/1.jpg" alt="image" />
<article class="text css3-3 css3-4">
<h1>space1 </h1>
</article>
</div>
<div class="container right">
<img src="images/2.jpg" alt="image" />
<article class="text css3-4">
<h1>space2</h1>
</article>
</div>
<hr />
</div>
</body>
</html>
CSS
* {
margin: 0;
padding: 0;
}
body {
}
.wrapper {
margin: 0 auto;
width: 960px;
padding: 30px;
position: relative;
}
.left {
float: left;
}
.right {
float: right;
}
hr {
border: none;
width: 100%;
height: 7px;
margin: 10px 0 10px 0;
clear: both;
}
a {
text-shadow: 1px 1px #efefef;
text-decoration: none;
}
b {
text-shadow: 1px 1px #efefef;
text-decoration: none;
}
header h1.main_head {
font: 36px/18px Georgia, Arial, sans-serif;
color: #838383;
text-shadow: 1px 1px #efefef;
text-align: center;
padding: 20px 0 20px 0;
}
.container {
border: 10px solid #fff;
position: relative;
overflow: hidden;
height: 200px;
-webkit-box-shadow: 0 0 3px #000;
-moz-box-shadow: 0 0 3px #000;
box-shadow: 0 0 3px #000;
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
transition: all .5s ease-out;
}
.container:hover {
cursor: pointer;
-webkit-box-shadow: 0 0 10px #000;
-moz-box-shadow: 0 0 10px #000;
box-shadow: 0 0 10px #000;
}
.container2 {
border: 10px solid #fff;
position: relative;
overflow: hidden;
height: 200px;
-webkit-box-shadow: 0 0 3px #000;
-moz-box-shadow: 0 0 3px #000;
box-shadow: 0 0 3px #000;
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
transition: all .5s ease-out;
}
.container2:hover {
cursor: pointer;
-webkit-box-shadow: 0 0 10px #000;
-moz-box-shadow: 0 0 10px #000;
box-shadow: 0 0 10px #000;
}
.text {
background: rgba(0,0,0,0.5);
color: white;
font: 14px Georgia,serif;
height: 80px;
width: inherit;
position: absolute;
}
.text a {
color: #fff;
display: block;
padding: 15px;
font-size: 16px;
font-weight: normal;
text-shadow: none;
text-decoration: none;
width: 400px;
}
/* CSS3 Right Effect */
article.css3-3 {
right: -400px;
top: 0;
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
-o-transition: all .5s ease-out;
transition: all .5s ease-out;
width: 400px;
}
.text a.css3-3 {
-webkit-transition: all .4s ease-out;
-moz-transition: all .4s ease-out;
-o-transition: all .5s ease-out;
transition: all .4s ease-out;
}
.text a.css3-3:hover {
color: #d0206a;
text-decoration: none;
}
.container:hover article.css3-3 {
right: 0;
}
/* CSS3 Left Effect */
article.css3-4 {
left: -400px;
bottom: 0;
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
-o-transition: all .5s ease-out;
transition: all .5s ease-out;
width: 400px;
}
.text a.css3-4 {
-webkit-transition: all .4s ease-out;
-moz-transition: all .4s ease-out;
-o-transition: all .5s ease-out;
transition: all .4s ease-out;
}
.text a.css3-4:hover {
color: #d0206a;
text-decoration: none;
}
.container:hover article.css3-4 {
left: 0;
}
Maybe I'm not understanding correctly, but is this what you're looking for?
<div class="container right">
<img src="http://placehold.it/350x150" alt="image" />
<article class="text css3-4">
<h1>space1</h1>
</article>
<article class="text css3-3 css3-4">
<h1>space2 </h1>
</article>
</div>