SCSS - add transition to after element
I want to add transition to after element on hover, problem is that is not working. I want to hover on image and add background-color over it and apply transition on .5s . Content is for testing only.
.imageGallery1 {
box-sizing: border-box;
height: 100%;
width: 100%;
position: relative;
&:hover {
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0.3;
transition: 0.5s;
}
}
}
css sass css-transitions
add a comment |
I want to add transition to after element on hover, problem is that is not working. I want to hover on image and add background-color over it and apply transition on .5s . Content is for testing only.
.imageGallery1 {
box-sizing: border-box;
height: 100%;
width: 100%;
position: relative;
&:hover {
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0.3;
transition: 0.5s;
}
}
}
css sass css-transitions
1
Can you please add relevant html and maybe the output CSS in a working code snippet
– SuperDJ
Jan 19 at 11:49
I don't know if that's possible, Try testing in with JQuery
– Thanveer Shah
Jan 19 at 12:09
add a comment |
I want to add transition to after element on hover, problem is that is not working. I want to hover on image and add background-color over it and apply transition on .5s . Content is for testing only.
.imageGallery1 {
box-sizing: border-box;
height: 100%;
width: 100%;
position: relative;
&:hover {
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0.3;
transition: 0.5s;
}
}
}
css sass css-transitions
I want to add transition to after element on hover, problem is that is not working. I want to hover on image and add background-color over it and apply transition on .5s . Content is for testing only.
.imageGallery1 {
box-sizing: border-box;
height: 100%;
width: 100%;
position: relative;
&:hover {
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0.3;
transition: 0.5s;
}
}
}
css sass css-transitions
css sass css-transitions
edited Jan 19 at 12:49
Freestyle09
asked Jan 19 at 11:46
Freestyle09Freestyle09
199216
199216
1
Can you please add relevant html and maybe the output CSS in a working code snippet
– SuperDJ
Jan 19 at 11:49
I don't know if that's possible, Try testing in with JQuery
– Thanveer Shah
Jan 19 at 12:09
add a comment |
1
Can you please add relevant html and maybe the output CSS in a working code snippet
– SuperDJ
Jan 19 at 11:49
I don't know if that's possible, Try testing in with JQuery
– Thanveer Shah
Jan 19 at 12:09
1
1
Can you please add relevant html and maybe the output CSS in a working code snippet
– SuperDJ
Jan 19 at 11:49
Can you please add relevant html and maybe the output CSS in a working code snippet
– SuperDJ
Jan 19 at 11:49
I don't know if that's possible, Try testing in with JQuery
– Thanveer Shah
Jan 19 at 12:09
I don't know if that's possible, Try testing in with JQuery
– Thanveer Shah
Jan 19 at 12:09
add a comment |
2 Answers
2
active
oldest
votes
Seems to work just fine at https://codepen.io/anon/pen/MZNjeZ assuming the container of .imageGallery1
has dimensions (width
, height
) so that it can expand to 100%
of it.
I said transition is not working, not hover
– Freestyle09
Jan 19 at 12:47
@Freestyle09 oh sorry, missed that. Which properties do want to transition? Also keep in mind that transition requires two states before and after. So the element that transitions must exist before starting the transition
– Gabriele Petrioli
Jan 19 at 12:56
I want to transit all properties which I defined in after element
– Freestyle09
Jan 19 at 17:05
add a comment |
I did something like this and it works!
& a {
position: relative;
display: inline-block;
height: 100%;
z-index: 1090;
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0;
transition: 0.5s opacity;
cursor: pointer;
}
&:hover::after {
opacity: 0.3;
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54266736%2fscss-add-transition-to-after-element%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Seems to work just fine at https://codepen.io/anon/pen/MZNjeZ assuming the container of .imageGallery1
has dimensions (width
, height
) so that it can expand to 100%
of it.
I said transition is not working, not hover
– Freestyle09
Jan 19 at 12:47
@Freestyle09 oh sorry, missed that. Which properties do want to transition? Also keep in mind that transition requires two states before and after. So the element that transitions must exist before starting the transition
– Gabriele Petrioli
Jan 19 at 12:56
I want to transit all properties which I defined in after element
– Freestyle09
Jan 19 at 17:05
add a comment |
Seems to work just fine at https://codepen.io/anon/pen/MZNjeZ assuming the container of .imageGallery1
has dimensions (width
, height
) so that it can expand to 100%
of it.
I said transition is not working, not hover
– Freestyle09
Jan 19 at 12:47
@Freestyle09 oh sorry, missed that. Which properties do want to transition? Also keep in mind that transition requires two states before and after. So the element that transitions must exist before starting the transition
– Gabriele Petrioli
Jan 19 at 12:56
I want to transit all properties which I defined in after element
– Freestyle09
Jan 19 at 17:05
add a comment |
Seems to work just fine at https://codepen.io/anon/pen/MZNjeZ assuming the container of .imageGallery1
has dimensions (width
, height
) so that it can expand to 100%
of it.
Seems to work just fine at https://codepen.io/anon/pen/MZNjeZ assuming the container of .imageGallery1
has dimensions (width
, height
) so that it can expand to 100%
of it.
answered Jan 19 at 11:56
Gabriele PetrioliGabriele Petrioli
150k23199256
150k23199256
I said transition is not working, not hover
– Freestyle09
Jan 19 at 12:47
@Freestyle09 oh sorry, missed that. Which properties do want to transition? Also keep in mind that transition requires two states before and after. So the element that transitions must exist before starting the transition
– Gabriele Petrioli
Jan 19 at 12:56
I want to transit all properties which I defined in after element
– Freestyle09
Jan 19 at 17:05
add a comment |
I said transition is not working, not hover
– Freestyle09
Jan 19 at 12:47
@Freestyle09 oh sorry, missed that. Which properties do want to transition? Also keep in mind that transition requires two states before and after. So the element that transitions must exist before starting the transition
– Gabriele Petrioli
Jan 19 at 12:56
I want to transit all properties which I defined in after element
– Freestyle09
Jan 19 at 17:05
I said transition is not working, not hover
– Freestyle09
Jan 19 at 12:47
I said transition is not working, not hover
– Freestyle09
Jan 19 at 12:47
@Freestyle09 oh sorry, missed that. Which properties do want to transition? Also keep in mind that transition requires two states before and after. So the element that transitions must exist before starting the transition
– Gabriele Petrioli
Jan 19 at 12:56
@Freestyle09 oh sorry, missed that. Which properties do want to transition? Also keep in mind that transition requires two states before and after. So the element that transitions must exist before starting the transition
– Gabriele Petrioli
Jan 19 at 12:56
I want to transit all properties which I defined in after element
– Freestyle09
Jan 19 at 17:05
I want to transit all properties which I defined in after element
– Freestyle09
Jan 19 at 17:05
add a comment |
I did something like this and it works!
& a {
position: relative;
display: inline-block;
height: 100%;
z-index: 1090;
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0;
transition: 0.5s opacity;
cursor: pointer;
}
&:hover::after {
opacity: 0.3;
}
}
add a comment |
I did something like this and it works!
& a {
position: relative;
display: inline-block;
height: 100%;
z-index: 1090;
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0;
transition: 0.5s opacity;
cursor: pointer;
}
&:hover::after {
opacity: 0.3;
}
}
add a comment |
I did something like this and it works!
& a {
position: relative;
display: inline-block;
height: 100%;
z-index: 1090;
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0;
transition: 0.5s opacity;
cursor: pointer;
}
&:hover::after {
opacity: 0.3;
}
}
I did something like this and it works!
& a {
position: relative;
display: inline-block;
height: 100%;
z-index: 1090;
&::after {
content: '>';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $main-color;
opacity: 0;
transition: 0.5s opacity;
cursor: pointer;
}
&:hover::after {
opacity: 0.3;
}
}
answered Jan 21 at 11:23
Freestyle09Freestyle09
199216
199216
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54266736%2fscss-add-transition-to-after-element%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Can you please add relevant html and maybe the output CSS in a working code snippet
– SuperDJ
Jan 19 at 11:49
I don't know if that's possible, Try testing in with JQuery
– Thanveer Shah
Jan 19 at 12:09