SCSS - add transition to after element












0















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;
}
}
}









share|improve this question




















  • 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
















0















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;
}
}
}









share|improve this question




















  • 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














0












0








0








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;
}
}
}









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












2 Answers
2






active

oldest

votes


















0














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.






share|improve this answer
























  • 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



















0














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;
}
}





share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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.






    share|improve this answer
























    • 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
















    0














    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.






    share|improve this answer
























    • 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














    0












    0








    0







    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.






    share|improve this answer













    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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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



















    • 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













    0














    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;
    }
    }





    share|improve this answer




























      0














      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;
      }
      }





      share|improve this answer


























        0












        0








        0







        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;
        }
        }





        share|improve this answer













        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;
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 21 at 11:23









        Freestyle09Freestyle09

        199216




        199216






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Liquibase includeAll doesn't find base path

            How to use setInterval in EJS file?

            Petrus Granier-Deferre