before pseudo-element covering inner content

Mehran

so I have created a div as the parent with a span element inside, holding the title for the parent and I have defined a css before pseudo-element (:before) for the parent so when user hovers over the element it has a nice transition but the problem is : the :before covers the span element so the title gets hidden which is not acceptable of course !

here's the sample code on jsfiddle : http://jsfiddle.net/msU6p/4/

here's the HTML :

<div class="menuItem_Large" id="node_1_menu">
    <span>menu item 1</span>
</div> 

and styles :

.menuItem_Large
{
   position: absolute;
   left: 0px;
   display: inline-block;
   padding-left: 6px;
   padding-right: 6px;
   height: 20px;
   line-height: 16px;
   vertical-align: middle;
   background-image : url('http://i58.tinypic.com/21eyrk8.png');
   background-repeat: repeat;
   cursor:pointer;
}

.menuItem_Large:before
{
    content:"";
    position:absolute;
    top:0px;
    left:0px;
    width:0%;
    height:20px;
    background-color:rgba(0,200,255,1);
    transition:width 0.3s ease-out;
}

.menuItem_Large:hover:before
{
    width:100%;
}

.menuItem_Large span
{
    color: white;
    font-size: 16px;
}
  • Please Note :

I tried using z-index on span setting it to 2 or so but It doesn't work and when I set z-index of before element to negative It goes under the parent's background-image which is not good

does anyone know where's my mistake or what can I possibly do to make this work only using css ?

Thanks in Advance

Anon

display:block; position:relative; for <span> can help to you. DEMO

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CSS Transition on the 'content' property of :before pseudo element

From Dev

CSS Transition on the 'content' property of :before pseudo element

From Java

Is there a way to use SVG as content in a pseudo element :before or :after

From Dev

Pseudo element :hover on ::before

From Dev

Pseudo element content with JQuery

From Dev

::selection pseudo selector ignoring ::before pseudo element

From Dev

getComputedStyle from the `before` pseudo element

From Dev

Pseudo element :before and overflow hidden

From Dev

Multiple values in a ::before pseudo element

From Dev

disable touch on the pseudo content of an element

From Dev

element + element cant access :before pseudo

From Dev

Unicode in data-content for pseudo element content

From Dev

How to set :disabled pseudo element/class on :before pseudo element

From Dev

Use content of an element in attr() of pseudo-element

From Dev

create a border effect around element when there is a pseudo element covering or hiding part of the element

From Dev

Making content appear below the :before pseudo selector?

From Dev

Css pseudo-element ::before(2); :before and ::before

From Dev

Why ::before pseudo-element not working with :visited pseudo-class?

From Dev

Select text in ::before or ::after pseudo-element

From Dev

Removing an element added by ::before pseudo selector

From Dev

Can't get before pseudo element to work

From Dev

CSS, using display:table with before pseudo element

From Dev

::before/::after pseudo class not working on video element

From Dev

::before pseudo-element behind child border

From Dev

Is there a third pseudo element, like after and before

From Dev

Creating a shape using a :before pseudo element in CSS

From Dev

::before pseudo-element behind child border

From Dev

Can't get before pseudo element to work

From Dev

How to use character code with ::before pseudo element

Related Related

  1. 1

    CSS Transition on the 'content' property of :before pseudo element

  2. 2

    CSS Transition on the 'content' property of :before pseudo element

  3. 3

    Is there a way to use SVG as content in a pseudo element :before or :after

  4. 4

    Pseudo element :hover on ::before

  5. 5

    Pseudo element content with JQuery

  6. 6

    ::selection pseudo selector ignoring ::before pseudo element

  7. 7

    getComputedStyle from the `before` pseudo element

  8. 8

    Pseudo element :before and overflow hidden

  9. 9

    Multiple values in a ::before pseudo element

  10. 10

    disable touch on the pseudo content of an element

  11. 11

    element + element cant access :before pseudo

  12. 12

    Unicode in data-content for pseudo element content

  13. 13

    How to set :disabled pseudo element/class on :before pseudo element

  14. 14

    Use content of an element in attr() of pseudo-element

  15. 15

    create a border effect around element when there is a pseudo element covering or hiding part of the element

  16. 16

    Making content appear below the :before pseudo selector?

  17. 17

    Css pseudo-element ::before(2); :before and ::before

  18. 18

    Why ::before pseudo-element not working with :visited pseudo-class?

  19. 19

    Select text in ::before or ::after pseudo-element

  20. 20

    Removing an element added by ::before pseudo selector

  21. 21

    Can't get before pseudo element to work

  22. 22

    CSS, using display:table with before pseudo element

  23. 23

    ::before/::after pseudo class not working on video element

  24. 24

    ::before pseudo-element behind child border

  25. 25

    Is there a third pseudo element, like after and before

  26. 26

    Creating a shape using a :before pseudo element in CSS

  27. 27

    ::before pseudo-element behind child border

  28. 28

    Can't get before pseudo element to work

  29. 29

    How to use character code with ::before pseudo element

HotTag

Archive