user1328586
user1328586

Reputation:

I want to change the div height by hovering on the text INSIDE the div

I have a outer div named Title which has style="width=100%" and inner div named more

So I want to change height of outer div by hovering on inner div(smoothly.. using transition)

Is it possible using css??

I want something like

transition: height .4s;
-moz-transition: height .4s; 
-webkit-transition: height .4s; 
-o-transition: height .4s;  
-ms-transition: height .4s;

my title css code

#title{
    display:inline-block;
    background-color:#000;
    position:absolute;
    top:20px;
    left:20px;
    right:20px;
    margin:0px;
    padding:0px;
    height:42px;
    min-width:800px;
}

My more css code

#more{
    padding-left:10px;
    color:#999;
    text-decoration:underline;
    font-size:10px;
}

All the below code are not working

can i do it through JavaScript???

Upvotes: 0

Views: 225

Answers (1)

Christoph
Christoph

Reputation: 51201

You cannot target an ancestor element in css without using the Subject Identifier which is introduced in CSS Selectors Level 4 Draft which is supported by none of the browsers at the moment.

In farther future you can write (the exclamation mark is a temporary solution):

!#Title name:hover{
    /* css stuff */
}

You can however do one of the following things:

Declare display:table on your #title div and animate the #more div like in this example. Works at least in chrome;)

Or you just use javascript (or perhaps jQuery), apply an eventhandler and either modify the height of #title directly or apply a class holding the transition effect.

Upvotes: 1

Related Questions