I am trying to mimic the hover transitions for buttons as found on this page.
I have the following so far:
.hs-button {
font-size: 16px;
font-family: "Raleway", sans-serif;
text-transform: uppercase;
line-height: 1em;
color: #333333;
letter-spacing: 0;
background: #fff336;
display: inline-block;
position: relative;
cursor: pointer;
-webkit-transition: 0.3s;
transition: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
input[type="submit"]:hover {
text-decoration: none;
transform: translateY(0px);
-webkit-transform: translateY(0px);
}
input[type="submit"]:hover {
border: 3px solid #000;
background-color: #000;
color: #fff336;
}
input[type="submit"]:hover:after {
height: 100%;
}
input[type="submit"]:after {
content: "";
background: #000;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 0;
z-index: -1;
-webkit-transition: 0.3s;
transition: 0.3s;
}
<div class="hs_submit">
<div class="actions">
<input type="submit" value="DOWNLOAD NOW!" class="hs-button primary large">
</div>
</div>
The above button is the only button on my page and with the following above code, I'd expect it the black background to hover from bottom to top, but it's not - why?
Edit:
[Preview link to page][2]
You don't have to use pseudo-element with input tag (Can I use a :before or :after pseudo-element on an input field?). Consider adding pseudo element on a container. Also remove the background of your input. It need to be transparent so you can see the effect of pseudo-element behind.
Here is an example:
.actions {
display:inline-block;
position:relative;
}
.hs-button {
font-size: 16px;
font-family: "Raleway", sans-serif;
text-transform: uppercase;
line-height: 1em;
color: #333333;
letter-spacing: 0;
padding:20px;
border:none;
display: inline-block;
position: relative;
cursor: pointer;
z-index:1;
}
.actions:hover input[type="submit"] {
color: #fff336;
background:transparent;
}
.actions:before {
content: "";
background: #000;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 0;
z-index:0;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.actions:hover::before {
height:100%;
}
<div class="hs_submit">
<div class="actions">
<input type="submit" value="DOWNLOAD NOW!" class="hs-button primary large">
</div>
</div>
input not support ::before ::after you can use
<Button>
than add ::before ::after .
LIke https://jsfiddle.net/ufL55gfw/1/
Try below
.slider-button {
margin-top: 70px;
}
#media (max-width: 1220px) {
.slider-button {
margin-top: 30px;
}
}
.slider-button .button {
text-align: left;
}
#media (max-width: 1220px) {
.slider-button .button {
text-align: center;
}
}
.slider-button .button {
text-align: left;
}
.button {
text-align: center;
}
.button a{text-decoration:none;}
.button__item {
font-family: "Raleway", sans-serif;
font-weight: 500;
text-transform: uppercase;
font-size: 1.313rem;
line-height: 1em;
color: #333333;
letter-spacing: 0;
background: #fff336;
padding: 32.5px 65px;
display: inline-block;
position: relative;
cursor: pointer;
-webkit-transition: 0.3s;
transition: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.button__item:hover {
text-decoration: none;
-webkit-transform: translateY(0px);
transform: translateY(0px);
}
.button__item:hover:after {
height: 100%;
}
.button__item:after {
content: "";
background: #fff;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 0;
z-index: -1;
-webkit-transition: 0.3s;
transition: 0.3s;
}
<div class="slider-button"><div class="button">DOWNLOAD NOW</div></div>
Related
I'm really struggling with an issue that is hard to describe. I've included a JSFiddle here: https://jsfiddle.net/z8L392ug/
enter code here
Basically the issue is that I have a news API that I am calling for F1 stories. I can call the API successfully, but the component on the page that houses the news articles isn't working correctly. The correct functionality can be found on this site:
https://drivetodescribe.com/news.html (please note this page has to be updated manually and isn't calling the news API)
Can anyone help me or point me in the right direction to get these components working correctly??
Writing a question
In order to resolve your issue, you should provide us with enough information to answer your questions.
but the component on the page that houses the news articles isn't working correctly.
Is rather vague. Other people don't have the context you're working with and have to go on a scavenger hunt to find what you actually mean.
you could rewrite your question like.
"I render a list of tiles . The data is coming from an api call. In each tile has a button on the top right. Clicking the button should cause the tile's content to change. this is not happening"
Attaching handlers
you have a function in your code that runs when the page loads. That piece of code attache a click handler to the .mc-btn-action elements.
When this function runs. it will look for all items in the DOM that have that class.
When your api-call is still fetching, this piece of code cannot find any elements. (as they will only be added when the api call finishes)
Attaching it after the tiles are added to the DOM.
you can attach the handlers whenever you're certain the elements are in the DOM. For example in your render function
function renderCountries(countries) {
const countriesContainer = document.getElementById('myUL');
if (countries.length > 0) {
countriesContainer.innerHTML = countries
.map(country => cardTemplate(country))
.join(' ');
$('.material-card > .mc-btn-action').click(onHelmetClick);
} else {
countriesContainer.innerHTML = '<p>No countries found.</p>';
}
}
Example
$(function() {
$('.material-card > .mc-btn-action').click(onHelmetClick);
});
function onHelmetClick() {
var card = $(this).parent('.material-card');
var icon = $(this).children('i');
icon.addClass('fa-spin-fast');
if (card.hasClass('mc-active')) {
card.removeClass('mc-active');
window.setTimeout(function() {
icon
.removeClass('fa-arrow-left')
.removeClass('fa-spin-fast')
.addClass('fa-bars');
}, 800);
} else {
card.addClass('mc-active');
window.setTimeout(function() {
icon
.removeClass('fa-bars')
.removeClass('fa-spin-fast')
.addClass('fa-arrow-left');
}, 800);
}
}
function myFunction() {
var input, filter, ul, li, a, i, txtValue;
input = document.getElementById('myInput');
filter = input.value.toUpperCase();
ul = document.getElementById("myUL");
li = ul.getElementsByTagName('li');
for (i = 0; i < li.length; i++) {
a = li[i].getElementsByTagName("a")[0];
txtValue = a.textContent || a.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
}
}
function onHelmetClick() {
var card = $(this).parent('.material-card');
var icon = $(this).children('i');
icon.addClass('fa-spin-fast');
if (card.hasClass('mc-active')) {
card.removeClass('mc-active');
window.setTimeout(function() {
icon
.removeClass('fa-arrow-left')
.removeClass('fa-spin-fast')
.addClass('fa-bars');
}, 800);
} else {
card.addClass('mc-active');
window.setTimeout(function() {
icon
.removeClass('fa-bars')
.removeClass('fa-spin-fast')
.addClass('fa-arrow-left');
}, 800);
}
}
function renderCountries(countries) {
const countriesContainer = document.getElementById('myUL');
if (countries.length > 0) {
countriesContainer.innerHTML = countries
.map(country => cardTemplate(country))
.join(' ');
$('.material-card > .mc-btn-action').click(onHelmetClick);
} else {
countriesContainer.innerHTML = '<p>No countries found.</p>';
}
}
function cardTemplate(data) {
return `
<li class="li-no-hover"><div class="profile">
<article class="material-card Profile">
<a style="text-decoration: none;" href="">
<h2><strong>${data.headline}</strong></h2>
<div class="mc-content">
<div class="img-container">
<img src="${data.image}" alt="Sidepods" style="height: 100%; background-position: center;";>
</div></a>
<div class="mc-description" style="text-align: left; line-height: 135%;">
<p style="text-align: center;">${data.story}</p>
<div class="mc-description-bottom">
<h5>${data.byline}</h5></div>
</div></div>
<a class="mc-btn-action">
<img style="width:60%" src="/page-assets/d2d-icon(left).svg"></a>
</article></div></li>
`;
}
(function start() {
const url =
'https://script.google.com/macros/s/AKfycbzXIL78B0c6lF10Ekhj9c77NXfhyoeFtBIR7RaswQMNv36P4P1laLu03J0WjngMgaXE/exec';
fetch(url)
.then(res => {
return res.json();
})
.then(json => {
COUNTRIES = json.data;
renderCountries(COUNTRIES);
addDropdownOptions(COUNTRIES);
});
})();
$(function() {
$('.material-card > .mc-btn-action').click(onHelmetClick);
});
#import url('https://fonts.googleapis.com/css2?family=Aclonica&family=Audiowide&family=Black+Ops+One&family=Bungee&family=Bungee+Hairline&family=Bungee+Inline&family=Bungee+Outline&family=Bungee+Shade&family=Days+One&family=Michroma&family=Monoton&family=Racing+Sans+One&family=Titillium+Web:ital,wght#0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700&display=swap');
#font-face {
font-family: D2DTitle1;
src: url(fonts/Formula1-Regular_web_0.ttf);
}
#font-face {
font-family: D2DTitle2;
src: url(fonts/Formula1-Bold_web_0.ttf);
}
#font-face {
font-family: D2DTitle3;
src: url(fonts/Formula1-Wide_web_0.ttf);
}
#font-face {
font-family: D2DBody1;
src: url(fonts/TitilliumWeb-ExtraLight.ttf);
}
#font-face {
font-family: D2DBody2;
src: url(fonts/TitilliumWeb-Light.ttf);
}
#font-face {
font-family: D2DBody3;
src: url(fonts/TitilliumWeb-Regular.ttf);
}
#font-face {
font-family: D2DBody4;
src: url(fonts/TitilliumWeb-SemiBold.ttf);
}
#font-face {
font-family: D2DBody5;
src: url(fonts/TitilliumWeb-SuperBold.ttf);
}
#font-face {
font-family: D2DBody6;
src: url(fonts/TitilliumWeb-SuperSuperBlack.ttf);
}
#font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?oymsdl');
src: url('fonts/icomoon.eot?oymsdl#iefix') format('embedded-opentype'), url('fonts/icomoon.ttf?oymsdl') format('truetype'), url('fonts/icomoon.woff?oymsdl') format('woff'), url('fonts/icomoon.svg?oymsdl#icomoon') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
[class^="icon-"],
[class*=" icon-"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-news:before {
content: "\e900";
}
.icon-flag:before {
content: "\e901";
}
.icon-helmet:before {
content: "\e902";
}
.icon-wheel:before {
content: "\e903";
}
.icon-specials:before {
content: "\e91c";
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #000000;
color: #ffffff;
box-sizing: border-box;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: 'D2DBody2';
min-height: 100vh;
text-align: center;
overflow-x: hidden;
}
body>* {
width: 100%;
}
h1,
h2,
h3,
h7 {
text-transform: uppercase;
text-align: center;
}
h1 {
font-size: 35pt;
color: black;
text-shadow: 0 0 4px white;
font-family: 'D2DTitle2', sans-serif;
margin: 1.5rem 0;
}
h2 {
font-size: 18pt;
color: white;
font-family: 'D2DTitle2', sans-serif;
}
h3 {
font-size: 14pt;
color: white;
text-align: center;
font-family: 'D2DTitle2', sans-serif;
}
h4 {
font-size: 11pt;
color: white;
text-align: left;
font-family: 'D2DBody1';
}
h5 {
font-size: 8pt;
font-style: italic;
margin-right: 10px;
color: white;
text-align: right;
font-family: 'D2DBody1';
}
h6 {
font-size: 10pt;
color: white;
text-align: center;
font-family: 'D2DBody1';
}
h7 {
font-size: 12pt;
color: white;
text-align: center;
font-family: 'D2DTitle2', sans-serif;
}
p {
font-size: 12pt;
margin-bottom: 12pt;
font-family: 'D2DBody1', sans-serif;
}
h8 {
font-size: 12pt;
margin-bottom: 12pt;
font-family: 'D2DBody4', sans-serif;
}
.container {
max-width: 90%;
margin: 0 auto;
}
#about {
top: 1em;
background-color: black;
font-weight: 500;
font-family: 'D2DTitle2';
}
#media screen and (max-width: 915px) {
h1 {
font-size: 25pt;
}
h2 {
font-size: 14pt;
}
p {
font-size: 11pt;
}
}
.countries-container {
margin-top: 2rem;
margin-bottom: 2rem;
width: 100%;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.countries-container .card {
position: relative;
width: 250px;
margin: 0 1rem 1rem 0;
background-color: #4D4D4D;
cursor: pointer;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.countries-container .card .card-header .card-title {
color: white;
display: absolute;
margin: 0;
text-align: center;
line-height: 1.2;
padding: 0.5rem 0.75rem;
white-space: pre-wrap;
}
.countries-container .card .card-header img {
display: absolute;
height: 167px;
-o-object-fit: cover;
object-fit: cover;
}
.countries-container .card .card-body {
padding: 0.5rem 0.75rem;
}
.countries-container .card .card-body .card-body-item {
margin-bottom: 0.5rem;
}
.countries-container .card .card-body .card-body-item:last-child {
margin-bottom: 0;
}
.countries-container .card .card-body .card-body-item p {
margin: 0;
}
.card-img-caption .card-img-top {
z-index: 0;
}
.linkicons {
width: 30px;
}
.race-container {
position: relative;
text-align: center;
color: white;
height: 150px;
width: 90%;
overflow: hidden;
background-size: cover;
background-position: center;
}
.r-result {
position: absolute;
color: white;
top: 40%;
right: 5%;
font-family: 'D2DTitle2', sans-serif;
font-size: 1.5em;
text-shadow: .1em .1em #4D4D4D;
text-transform: uppercase;
-webkit-text-stroke-width: 1.3px;
-webkit-text-stroke-color: black;
}
.points {
position: absolute;
color: white;
top: 70%;
right: 5%;
font-family: 'D2DTitle2', sans-serif;
font-size: 1.5em;
text-shadow: .1em .1em #4D4D4D;
text-transform: uppercase;
-webkit-text-stroke-width: 1.3px;
-webkit-text-stroke-color: black;
}
.q-result {
position: absolute;
color: white;
top: 10%;
right: 5%;
font-family: 'D2DTitle2', sans-serif;
font-size: 1.5em;
text-shadow: .1em .1em #4D4D4D;
text-transform: uppercase;
-webkit-text-stroke-width: 1.3px;
-webkit-text-stroke-color: black;
}
.round-name {
position: absolute;
color: white;
top: 40%;
left: 5%;
font-family: 'D2DTitle2', sans-serif;
font-size: 1.5em;
text-shadow: .1em .1em #4D4D4D;
text-transform: uppercase;
-webkit-text-stroke-width: 1.3px;
-webkit-text-stroke-color: black;
}
.specials {
position: relative;
text-align: center;
color: white;
width: 90%;
overflow: hidden;
background-size: cover;
background-position: center;
font-family: 'D2DTitle2', sans-serif;
font-size: 30px;
text-transform: uppercase;
}
.grid-container {
display: grid;
grid-template-columns: 25% 25%;
grid-gap: 50%;
font-size: 3em;
}
.countries-container .profile {
position: relative;
width: 300px;
margin: 1em 1em 1em 1em;
background-color: #000000;
cursor: pointer;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.countries-container .circuit {
position: relative;
width: 275px;
margin: .75em .75em .75em .75em;
background-color: #000000;
cursor: pointer;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.material-card {
position: relative;
padding-bottom: calc(100% - 16px);
margin-bottom: 1em;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 2px solid #fff;
}
.material-card h2 {
position: absolute;
top: calc(100% - 54px);
left: 0;
width: 100%;
height: 54px;
padding: 10px 16px;
color: #fff;
margin: 0;
z-index: 10;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card h2 span {
display: block;
font-size: 14px;
}
.material-card h2 strong {
display: block;
font-size: 12px;
}
.material-card .mc-description {
position: absolute;
right: .5em;
left: .5em;
bottom: .5em;
overflow: hidden;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: all 1.2s;
-moz-transition: all 1.2s;
-ms-transition: all 1.2s;
-o-transition: all 1.2s;
transition: all 1.2s;
text-align: left;
}
.material-card .mc-footer {
height: 0;
overflow: hidden;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card .img-container {
overflow: hidden;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 3;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card.mc-active .mc-description {
top: 30px;
padding-top: 2em;
padding-bottom: 10px;
overflow-y: scroll;
opacity: 1;
filter: alpha(opacity=100);
color: white;
}
.material-card.Profile h2 {
background-color: #000000;
}
.material-card.Profile.mc-active .mc-content {
background-color: #4d4d4d;
}
.material-card.circuit h2 {
background-color: #000000;
}
.material-card.circuit.mc-active .mc-content {
background-color: #4d4d4d;
}
.material-card.mc-active h2 {
top: 0;
padding: 10px 0px 0px 40px;
}
.material-card .mc-content {
position: absolute;
right: 0;
top: 0;
bottom: 0px;
left: 0;
text-align: center;
overflow: hidden;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card .mc-btn-action {
position: absolute;
right: 2px;
top: 2px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
width: 44px;
height: 44px;
text-align: center;
color: #fff;
cursor: pointer;
z-index: 20;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card.mc-active .mc-btn-action {
top: calc(100% - 34px);
}
.material-card.mc-active .img-container {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
width: 54px;
height: 54px;
z-index: 30;
left: 0px;
top: 0px;
}
.material-card.mc-active .mc-description-bottom {
position: flex;
bottom: 0em;
right: 0;
text-align: left;
}
.no-hover:hover {
background-color: transparent;
}
#myInput {
background-color: #000;
width: 60%;
font-size: 16px;
font-family: "D2DTitle2";
color: #fff;
padding: 12px 20px 12px 20px;
border: 1.5px solid #fff;
margin-bottom: 5px;
}
.standings-column {
float: left;
width: 50%;
padding: 15px;
}
.standings-row:after {
content: "";
display: table;
clear: both;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 190%;
}
#-webkit-keyframes ticker {
0% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
visibility: visible;
}
100% {
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
}
}
#keyframes ticker {
0% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
visibility: visible;
}
100% {
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0);
}
}
.ticker-wrap {
position: inline-block;
top: 0;
width: 100%;
overflow: hidden;
height: 4rem;
background-color: rgba(0, 0, 0, 0.9);
padding-left: 100%;
}
.ticker {
display: inline-block;
height: 4rem;
line-height: 4rem;
white-space: nowrap;
padding-right: 100%;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
-webkit-animation-name: ticker;
animation-name: ticker;
-webkit-animation-duration: 30s;
animation-duration: 30s;
}
.ticker_item {
display: inline-block;
padding: 0 2rem;
font-size: 2rem;
color: white;
}
.panel-container {
display: flex;
width: 95%;
}
.panel {
color: white;
cursor: pointer;
flex: content;
margin: .3vw;
position: relative;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: .2vw solid #fff;
}
.panel h3 {
font-size: 2vw;
position: absolute;
text-align: center;
bottom: -.01em;
height: 100%;
width: 100%;
writing-mode: vertical-rl;
text-shadow: 0 0 5px black;
position: absolute;
background-color: #4d4d4d;
}
.panel.active {
flex: 22;
}
.panel.active h3 {
writing-mode: horizontal-tb;
margin-left: auto;
margin-right: auto;
width: 100%;
left: 0;
text-align: center;
padding: 0 0;
height: 2.5vw;
transform: rotate(-0deg);
font-size: 2vw;
border-top: .2vw solid #fff;
background-color: black;
}
h1,
h2,
h3,
h7 {
text-transform: uppercase;
text-align: center;
}
h1 {
font-size: 35pt;
color: black;
-webkit-text-stroke-width: 1.3px;
-webkit-text-stroke-color: white;
font-family: 'D2DTitle2', sans-serif;
margin: 1.5rem 0;
}
h2 {
font-size: 18pt;
color: white;
font-family: 'D2DTitle2', sans-serif;
}
h3 {
font-size: 14pt;
color: white;
text-align: center;
font-family: 'D2DTitle2', sans-serif;
}
h4 {
font-size: 11pt;
color: white;
text-align: left;
font-family: 'D2DBody1';
}
h5 {
font-size: 8pt;
font-style: italic;
margin-right: 10px;
color: white;
text-align: right;
font-family: 'D2DBody1';
}
h6 {
font-size: 10pt;
color: white;
text-align: center;
font-family: 'D2DBody1';
}
h7 {
font-size: 12pt;
color: white;
text-align: center;
font-family: 'D2DTitle2', sans-serif;
}
p {
font-size: 12pt;
margin-bottom: 12pt;
}
.container {
max-width: 90%;
margin: 0 auto;
}
.countries-container {
margin-top: 2rem;
margin-bottom: 2rem;
width: 100%;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.countries-container .profile {
position: relative;
width: 18.75em;
margin: 1em 1em 1em 1em;
background-color: #000000;
cursor: pointer;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.countries-container .circuit {
position: relative;
width: 18.75em;
margin: .75em .75em .75em .75em;
background-color: #000000;
cursor: pointer;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.material-card {
position: relative;
padding-bottom: calc(100% - 16px);
margin-bottom: 2em;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 2px solid #fff;
}
.material-card h2 {
position: absolute;
top: calc(100% - 2.4em);
left: 0;
width: 100%;
height: 2.4em;
padding: 10px 16px;
color: #fff;
margin: 0;
z-index: 10;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card h2 span {
display: block;
font-size: 0.7em;
}
.material-card h2 strong {
display: block;
font-size: 0.6em;
}
.material-card .mc-description {
position: absolute;
right: .5em;
left: .5em;
bottom: .5em;
overflow: hidden;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: all 1.2s;
-moz-transition: all 1.2s;
-ms-transition: all 1.2s;
-o-transition: all 1.2s;
transition: all 1.2s;
}
.material-card .mc-footer {
height: 0;
overflow: hidden;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card .img-container {
overflow: hidden;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 3;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card.mc-active .mc-description {
top: 40px;
padding-top: 2em;
padding-bottom: 2em;
overflow-y: scroll;
opacity: 1;
filter: alpha(opacity=100);
}
.material-card.Profile h2 {
background-color: #000000;
}
.material-card.Profile.mc-active .mc-content {
background-color: #4d4d4d;
}
.material-card.circuit h2 {
background-color: #000000;
}
.material-card.circuit.mc-active .mc-content {
background-color: #4d4d4d;
}
.material-card.mc-active h2 {
top: 0;
padding: 5px 0px 0px 2.5em;
}
.material-card .mc-content {
position: absolute;
right: 0;
top: 0;
bottom: 0px;
left: 0;
text-align: center;
overflow: hidden;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card .mc-btn-action {
position: absolute;
right: 2px;
top: 2px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
width: 54px;
height: 54px;
text-align: center;
color: #fff;
cursor: pointer;
z-index: 20;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.material-card.mc-active .mc-btn-action {
top: calc(100% - 2.6em);
}
.material-card.mc-active .img-container {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
width: 3.6em;
height: 3.6em;
z-index: 30;
left: 0px;
top: 0px;
}
.material-card.mc-active .mc-description-bottom {
position: flex;
bottom: 0;
left: 0;
}
.material-card.mc-active .mc-description {
top: 30px;
padding-top: 2em;
opacity: 1;
filter: alpha(opacity=100);
color: #fff;
}
#myInput {
background-color: #000;
width: 60%;
font-size: 16px;
font-family: "D2DTitle2";
color: #fff;
padding: 12px 20px 12px 20px;
border: 1.5px solid #fff;
margin-bottom: 5px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<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>Drive to Describe: News</title>
<meta name="www.drivetodescribe.com" content="News" />
<link rel="stylesheet" href="../style/style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DXPBR1GF8S"></script>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
</head>
<body>
<hr style="height:1px;background-color:white">
<h1>News</h1>
</header>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search On Page..">
<ul id="myUL" class="countries-container container">
</ul>
</div>
</body>
</html>
Hi this is similar question to my last one but diffrent.
I am trying to add text to a href'd image inside a div tag.
When you click on the image only orange is shown. I would appreciate for someone to help me add text below image.
The scenario is when you click a picture you are presented with nice view. Small things are the hardest..
Desired output after clicking:
.class2 {
position:relative;
width:25%;
height:100%;
min-height:100%;
background-size: cover;
background: url('https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg');
}
.class2:after {
width:100%!important;
height:100%!important;
background-size: cover!important;
content: '';
opacity: 0;
position:absolute;
z-index:1;
top: 0;
left: 0;
bottom: 0;
right: 0;
border-radius: inherit;
transition: opacity .3s;
background: url('https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg');
}
.services .icon-box {
text-align: center;
border: 1px solid #ebebeb;
padding: 80px 20px;
transition: transform 0.3s ease-in-out 0s;
border-radius: 4px;
}
.services .icon-box .icon {
margin: 0 auto;
width: 64px;
height: 64px;
background: #009ee3;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
transition: 0.3s;
}
.services .icon-box .icon i {
color: #151515;
font-size: 28px;
transition: ease-in-out 0.3s;
}
.services .icon-box h4 {
font-weight: 700;
margin-bottom: 15px;
font-size: 24px;
}
.services .icon-box h4 a {
color: #fff;
transition: ease-in-out 0.3s;
}
.services .icon-box h4 a:hover {
color: #FFC451;
}
.services .icon-box p {
line-height: 24px;
font-size: 14px;
margin-bottom: 0;
}
.services .icon-box:hover {
border-color: #fff;
box-shadow: 0px 0 25px 0 rgba(0, 0, 0, 0.1);
transform: translateY(-10px);
}
<a href="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg" class="" data-tooltip="asdasdas" title="Web 3" >
<div class="icon-box class2">
<h4>Wassup</h4>
<br/><br/><br/><br/>
</div>
</a>
Not trivial since you are messing with pseudo elements
This one will take the image source from the anchor tag and the text from the header tag - but otherwise pretty much the same as my previous answer
const res = document.getElementById("res");
document.querySelector("a div.icon-box").addEventListener("click", function(e) {
const tgt = e.target;
if (tgt.classList.contains("icon-box")) {
e.preventDefault(); // stop the link
const src = tgt.closest("a").href; // cannot get the backgeound image of a pseudo element
const text = tgt.querySelector("h4").textContent;
res.innerHTML = `<div style="text-align:center"><img src="${src}" /><br><span>${text}</span></div>`
res.hidden = false;
}
})
#res {
position: absolute;
top: 0;
left: 0;
}
.class2 {
position: relative;
width: 25%;
height: 100%;
min-height: 100%;
background-size: cover;
background: url('https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg');
}
.class2:after {
width: 100%!important;
height: 100%!important;
background-size: cover!important;
content: '';
opacity: 0;
position: absolute;
z-index: 1;
top: 0;
left: 0;
bottom: 0;
right: 0;
border-radius: inherit;
transition: opacity .3s;
background: url('https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg');
}
.services .icon-box {
text-align: center;
border: 1px solid #ebebeb;
padding: 80px 20px;
transition: transform 0.3s ease-in-out 0s;
border-radius: 4px;
}
.services .icon-box .icon {
margin: 0 auto;
width: 64px;
height: 64px;
background: #009ee3;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
transition: 0.3s;
}
.services .icon-box .icon i {
color: #151515;
font-size: 28px;
transition: ease-in-out 0.3s;
}
.services .icon-box h4 {
font-weight: 700;
margin-bottom: 15px;
font-size: 24px;
}
.services .icon-box h4 a {
color: #fff;
transition: ease-in-out 0.3s;
}
.services .icon-box h4 a:hover {
color: #FFC451;
}
.services .icon-box p {
line-height: 24px;
font-size: 14px;
margin-bottom: 0;
}
.services .icon-box:hover {
border-color: #fff;
box-shadow: 0px 0 25px 0 rgba(0, 0, 0, 0.1);
transform: translateY(-10px);
}
<a href="https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg" class="" data-tooltip="asdasdas" title="Web 3">
<div class="icon-box class2">
<h4>Wassup</h4>
<br/><br/><br/><br/>
</div>
</a>
<div id="res" hidden></div>
just a relative simple question I think but can't find what to change. I you click to this input field you get a gradient color on the bottom of the field. I need to add something to get a red gradient color to the bottom when the page is loaded (so not clicked), when there is clicked the gradient changes to that yellow to pink gradient. thanks in advance!
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body, html {
height: 100%;
font-family: Poppins-Regular, sans-serif;
}
/*---------------------------------------------*/
a {
font-family: Poppins-Regular;
font-size: 14px;
line-height: 1.7;
color: #666666;
margin: 0px;
transition: all 0.4s;
-webkit-transition: all 0.4s;
-o-transition: all 0.4s;
-moz-transition: all 0.4s;
}
a:focus {
outline: none !important;
}
a:hover {
text-decoration: none;
color: #6a7dfe;
color: -webkit-linear-gradient(left, #21d4fd, #b721ff);
color: -o-linear-gradient(left, #21d4fd, #b721ff);
color: -moz-linear-gradient(left, #21d4fd, #b721ff);
color: linear-gradient(left, #21d4fd, #b721ff);
}
/*---------------------------------------------*/
h1,h2,h3,h4,h5,h6 {
margin: 0px;
}
p {
font-family: Poppins-Regular;
font-size: 14px;
line-height: 1.7;
color: #666666;
margin: 0px;
}
ul, li {
margin: 0px;
list-style-type: none;
}
/*---------------------------------------------*/
input {
outline: none;
border: none;
}
textarea {
outline: none;
border: none;
}
textarea:focus, input:focus {
border-color: transparent !important;
}
/*------------------------------------------------------------------
[ Input ]*/
.wrap-input100 {
width: 100%;
position: relative;
border-bottom: 2px solid #adadad;
margin-bottom: 37px;
}
.input100 {
font-family: Poppins-Regular;
font-size: 15px;
color: #555555;
line-height: 1.2;
display: block;
width: 100%;
height: 45px;
background: transparent;
padding: 0 5px;
}
/*---------------------------------------------*/
.focus-input100 {
position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
pointer-events: none;
}
.focus-input100::before {
content: "";
display: block;
position: absolute;
bottom: -2px;
left: 0;
width: 0;
height: 2px;
-webkit-transition: all 0.4s;
-o-transition: all 0.4s;
-moz-transition: all 0.4s;
transition: all 0.4s;
background: #6a7dfe;
background: -webkit-linear-gradient(left, yellow, #b721ff);
background: -o-linear-gradient(left, yellow, #b721ff);
background: -moz-linear-gradient(left, yellow, #b721ff);
background: linear-gradient(left, yellow, #b721ff);
}
.focus-input100::after {
font-family: Poppins-Regular;
font-size: 15px;
color: #999999;
line-height: 1.2;
content: attr(data-placeholder);
display: block;
width: 100%;
position: absolute;
top: 16px;
left: 0px;
padding-left: 5px;
-webkit-transition: all 0.4s;
-o-transition: all 0.4s;
-moz-transition: all 0.4s;
transition: all 0.4s;
}
.input100:focus + .focus-input100::after {
top: -15px;
}
.input100:focus + .focus-input100::before {
width: 100%;
}
.has-val.input100 + .focus-input100::after {
top: -15px;
}
.has-val.input100 + .focus-input100::before {
width: 100%;
}
/*------------------------------------------------------------------
[ Responsive ]*/
#media (max-width: 576px) {
.wrap-login100 {
padding: 77px 15px 33px 15px;
}
}
/*------------------------------------------------------------------
[ Alert validate ]*/
.validate-input {
position: relative;
}
.alert-validate::before {
content: attr(data-validate);
position: absolute;
max-width: 70%;
background-color: #fff;
border: 1px solid #c80000;
border-radius: 2px;
padding: 4px 25px 4px 10px;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
right: 0px;
pointer-events: none;
font-family: Poppins-Regular;
color: #c80000;
font-size: 13px;
line-height: 1.4;
text-align: left;
visibility: hidden;
opacity: 0;
-webkit-transition: opacity 0.4s;
-o-transition: opacity 0.4s;
-moz-transition: opacity 0.4s;
transition: opacity 0.4s;
}
.alert-validate::after {
content: "\f06a";
font-family: FontAwesome;
font-size: 16px;
color: #c80000;
display: block;
position: absolute;
background-color: #fff;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
right: 5px;
}
.alert-validate:hover:before {
visibility: visible;
opacity: 1;
}
.limiter {
width: 20%;
padding-top: 5%;
}
<div class="limiter">
<div class="wrap-input100 validate-input">
<span class="btn-show-pass">
<i class="zmdi zmdi-eye"></i>
</span>
<input class="input100" type="password" name="password">
<span class="focus-input100" data-placeholder="wachtwoord"></span>
</div>
</div>
Add CSS border-image and border-image-slice properties to the .wrap-input100 class
.wrap-input100 {
width: 100%;
position: relative;
margin-bottom: 37px;
border-bottom: 2px solid transparent;
border-image: linear-gradient(to right, #b721ff 0%, red 100%);
border-image-slice: 1;
}
I am trying to follow a tutorial so that when an input is selected the label rises and the line changes color. The problem is it creates a second line that displays in the middle of the input.
It should display like the one on this site here
I tried comparing the code then typed it exactly and it still isn't working.
My code is
html,
body {
height: 100%;
}
body {
display: grid;
font-family: Avenir;
-webkit-text-size-adjust: 100%;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: border-box;
}
.inp {
position: relative;
margin: auto;
width: 100%;
max-width: 280px;
}
.inp .label {
position: absolute;
top: 16px;
left: 0;
font-size: 16px;
color: #9098a9;
font-weight: 500;
transform-origin: 0 0;
transition: all 0.2s ease;
}
.inp .border {
position: absolute;
bottom: 0;
left: 0;
height: 2px;
width: 100%;
background: #07f;
transform: scaleX(0);
transform-origin: 0 0;
transition: all 0.15s ease;
}
.inp input {
-webkit-appearance: none;
width: 100%;
border: 0;
font-family: inherit;
padding: 12px 0;
height: 48px;
font-size: 16px;
font-weight: 500;
border-bottom: 2px solid #c8ccd4;
background: none;
border-radius: 0;
color: #223254;
transition: all 0.15s ease;
}
.inp input:hover {
background: rgba(34,50,84,0.03);
}
.inp input:not(:placeholder-shown) + span {
color: #5a667f;
transform: translateY(-26px) scale(0.75);
}
.inp input:focus {
background: none;
outline: none;
}
.inp input:focus + span {
color: #07f;
transform: translateY(-26px) scale(0.75);
}
.inp input:focus + span + .border {
transform: scaleX(1);
}
<!DOCTYPE html>
<html>
<head>
. . .
</head>
<body bgcolor="#f4b942">
<div>
<label for="inp" class="inp">
<input type="text" id="inp" placeholder=" ">
<span class="label">Insert Values</span>
<span class="border"></span>
</label>
</div>
</body>
</html>
Your code is not exactly same as the example link you mentioned. You have added <label> inside a <div>. <div> has a default display: block which is caused this issue. So there are two options 1) Remove <div> 2) Add change display: block to some other values like display: flex. It will work.
Below is code:
html,
body {
height: 100%;
}
body {
display: grid;
font-family: Avenir;
-webkit-text-size-adjust: 100%;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: border-box;
}
.div {
display: flex;
}
.inp {
position: relative;
margin: auto;
width: 100%;
max-width: 280px;
}
.inp .label {
position: absolute;
top: 16px;
left: 0;
font-size: 16px;
color: #9098a9;
font-weight: 500;
transform-origin: 0 0;
transition: all 0.2s ease;
}
.inp .border {
position: absolute;
bottom: 0;
left: 0;
height: 2px;
width: 100%;
background: #07f;
transform: scaleX(0);
transform-origin: 0 0;
transition: all 0.15s ease;
}
.inp input {
-webkit-appearance: none;
width: 100%;
border: 0;
font-family: inherit;
padding: 12px 0;
height: 48px;
font-size: 16px;
font-weight: 500;
border-bottom: 2px solid #c8ccd4;
background: none;
border-radius: 0;
color: #223254;
transition: all 0.15s ease;
}
.inp input:hover {
background: rgba(34, 50, 84, 0.03);
}
.inp input:not(:placeholder-shown)+span {
color: #5a667f;
transform: translateY(-26px) scale(0.75);
}
.inp input:focus {
background: none;
outline: none;
}
.inp input:focus+span {
color: #07f;
transform: translateY(-26px) scale(0.75);
}
<!DOCTYPE html>
<html>
<head>
. . .
</head>
<body bgcolor="#f4b942">
<div class="div">
<label for="inp" class="inp">
<input type="text" id="inp" placeholder=" ">
<span class="label">Insert Values</span>
<span class="border"></span>
</label>
</div>
</body>
</html>
All right? I'm having problems with an effect on CSS. Everything works perfectly until I put the code inside another div, and has a background that is not transparent. Look at the example below:
body {
background: #2ecc71;
padding:0;
margin:0;
}
#bg{
background: #000;
}
.container-button {
padding: 10em;
margin: 0 auto;
width: 1170px;
text-align: center;
display: block;
overflow: hidden;
}
/* GENERAL BUTTON STYLING */
.btn-more-info{
display:block;
overflow: hidden;
text-align: center;
display: inline-block;
float: left;
}
.btn-more-info a,
.btn-more-info a::after {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
test-ident: -9999px;
text-decoration: none;
}
.btn-more-info a {
background: none;
border: 2px solid #fff;
border-radius: 5px;
color: #fff;
display: block;
font-size: 14px;
font-weight: bold;
padding: 20px 50px;
position: relative;
text-transform: uppercase;
}
.btn-more-info a::before,
.btn-more-info a::after {
background: #fff;
content: '';
position: absolute;
z-index: -1;
}
.btn-more-info a:hover {
color: #2ecc71;
}
/* BUTTON EFFECT */
.btn-effect {
overflow: hidden;
}
.btn-effect::after {
/*background-color: #f00;*/
height: 100%;
left: -35%;
top: 0;
transform: skew(50deg);
transition-duration: 0.6s;
transform-origin: top left;
width: 0;
}
.btn-effect:hover:after {
height: 100%;
width: 135%;
}
.btn-send{
overflow: hidden;
text-align: center;
clear: both;
}
.btn-send a,
.btn-send a::after {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
test-ident: -9999px;
text-decoration: none;
}
.btn-send a {
background: none;
border: 2px solid #353B4C;
border-radius: 5px;
color: #353B4C;
display: inline-block;
font-size: 14px;
font-weight: bold;
padding: 20px 50px;
position: relative;
text-transform: uppercase;
}
.btn-send a::before,
.btn-send a::after {
background: #353B4C;
content: '';
position: absolute;
z-index: -1;
}
.btn-send a:hover {
color: #FFF;
}
<div id="bg">
<div class="container-button">
<div class="btn-more-info">
Continue lendo
</div>
<div class="btn-send">
Enviar mensagem
</div>
</div>
</div>
You see, if you remove the id="bg" effect functions normally.
Can anyone help me?
Thank U!
The problem is on the z-index of the :before and :after.
Try this:
.btn-more-info a::before,
.btn-more-info a::after {
background: #fff;
content: '';
position: absolute;
z-index: 0;
}
Also increase the z-index on the text inside the button.