Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotation of CSS arrow and javascript toggling

I have two div banners that have corresponding CSS arrows. When the banners are clicked, the javascript toggles between revealing and hiding the text underneath. Likewise, the respective arrows rotate down when the text is revealed and back up when the text is hidden.

Now, I want my first div banner to be revealed automatically when the page first loads. However, when I drew my CSS arrows, due to the padding of the div, I can't get the arrow in the first div to be the same as the arrow in the subsequent div(s) and line up properly.

http://jsfiddle.net/nVuQ2/1/

I've tried messing with the placement of the arrow:

.tri0 {
    margin-left: 20px;
    margin-top: 5px;
}

but the best I can do is push the tri0 arrow up to the padding of the h3 tag and it won't go any farther.

Is there a way that I can set a toggle flag in the toggleClass to make it say that the first div banner is already toggled and subsequent clicks make it un-toggle?

like image 319
noblerare Avatar asked Oct 02 '22 01:10

noblerare


1 Answers

Your issue happens because of the border of your tris elements. You are displaying different borders in each one of your elements, this will make them appear in different ways.

So basically I set them with the same borders values, the same rotation, and when your page first load it toggles your div and show your first message.

Note that is not necessary to have two different classes to toggle your element state, once that they are equal.

Check in the Fiddle.

Not sure if this is the solution that you wanted. But I hope that helps you.

Thanks.

like image 86
Eliezer Bernart Avatar answered Oct 19 '22 23:10

Eliezer Bernart