Seite 1 von 2

Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: So 28. Dez 2014, 18:59
von npage-user
Hallo mal wieder! :)

Ich hab kürzlich ein Akkordeon-Menü auf einer Testseite eingebaut.

http://www.holidaypark-uptodate.de/akkordeon-test.html

Jetzt ist es aber durch die Zeilen 35 und 36 (siehe angehängter Quellcode) so, dass jedes der Elemente 150 Pixel hoch wird, wenn man mit der Maus darüberfährt. Da ich aber verschieden umfangreiche Inhalte einbauen möchte, würde ich es gerne so realisieren, dass ich bei jedem Menüpunkt dieses Akkordeon-Menüs eine individuelle Höhe bestimmen kann. Denn wie man auf meiner Testseite sieht, wird zum Beispiel der Inhalt unter "Services" nicht mehr vollständig angezeigt. Hab es schon mit "height: auto;" versucht, will aber leider nicht funktionieren. :?

Hier mal der Code (HTML und CSS), vielleicht weiß jemand eine Lösung für mein Problem??

Code: Alles auswählen

<style>
#accordion .item {
    width: 698px;
    height: 30px; /* This is the height of the gray portion of each section */
    overflow: hidden;
    transition: height ease-in-out 1000ms; /* This is the bit that makes the slider...slide */
    -o-transition: height ease-in-out 1000ms;
    -moz-transition: height ease-in-out 1000ms;
    -webkit-transition: height ease-in-out 1000ms;
    border: 1px solid #ccc;  /* This sets the color and width of the border */
    border-radius: 5px;  /* This sets the roundness of the border corners */
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    margin-bottom: 5px;
}
#accordion a {
    display: block;
    height: 20px;
    line-height: 20px;
	background: #eeeeee; /* This is for all the old browsers */
	background: -moz-linear-gradient(top, #eeeeee 0%, #cccccc 100%); /* This gradient is for firefox */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(100%,#cccccc)); /* This one is for webkit browsers */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#cccccc',GradientType=0 ); /* and of course we musn't forget ie */
    padding: 5px;
    color: #333333;  /* This and the next few lines sets the font up for the header on each box */
    text-decoration: none;
    font-family: Georgia, Arial, Tahoma, sans-serif;
}
#accordion p {
    height: 150px;  /* This and the next few lines sets the font up for the content of each box */
    padding: 5px;
    font-family: Georgia, Arial, Tahoma, sans-serif;
    font-size: 13px;
}
#accordion div:hover {
    height: 150px; /* This is the total height when the scroll unfolds see the 150px in the element above */
}
#accordion div:hover a {
    border-bottom: 1px solid #cccccc;
}
</style>
<div id="accordion">
  <div class="item">
        <a href="#">Products</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam.</p>
    </div>
    <div class="item">
<a href="#">Services</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
    </div>
    <div class="item">
<a href="#">Contact</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam.</p>
    </div>
    <div class="item">
<a href="#">Support</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam.</p>
    </div>
</div>

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: So 28. Dez 2014, 21:01
von awardfan
Wenn ich das richtig sehe, ist das wohl eine reine CSS-Lösung. Da fällt mir auf den ersten Blick nur ein, dass du jedem einzelnen div noch eine id gibst und für die dann im CSS-Teil individuelle Höhen festlegst. Das ist aber aus meiner Sicht nicht sehr elegant.
Eine andere Lösung wäre auf der Basis von JavaScript. Ist ja eine nPage-Website und nPage bindet seit einiger Zeit automatisch zwingend jQuery und jQuery-UI ein. Auf dieser Basis ist dann schnell etwas gefunden, denn so ein Accordion gehört zur Standardausrüstung von jQuery-UI.
Dokumentiert ist das hier:
http://jqueryui.com/accordion/
Dort rechts auf der Seite findest du ein anklickbares Beispiel No auto height. das wäre das, was du brauchst.

Edit: Falls du doch lieber pures CSS möchtest, dann schau mal hier:
http://tympanus.net/codrops/2012/02/21/ ... with-css3/

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: So 28. Dez 2014, 21:13
von Inatktiv_220523
Du könntest

Code: Alles auswählen

overflow:auto;
einfügen ;)

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: Mo 29. Dez 2014, 09:02
von npage-user
@awardfan: Bin leider nicht damit zurechtgekommen. Habe die Dateien hochgeladen, das Menü hat am Ende auch geklappt, hat aber irgendwie das Design zerstört, also hab ich es wieder entfernt. Mit der CSS-Lösung bin ich dann recht weit gekommen, aber seltsamerweise ist auch hier der Inhalt nicht richtig ausgefahren (Was mache ich nur falsch?) :oops:
Franc hat geschrieben:Du könntest

Code: Alles auswählen

overflow:auto;
einfügen ;)
Danke, jetzt werden immerhin Scrollbalken angezeigt, die Höhe bleibt aber weiterhin gleich. Hab dann auch mal noch unten ein paar Kombinationen mit "height: 100%" und "height: auto;" probiert, hat dann aber immer noch nicht geklappt. Irgendwie bleibt das auf der Höhe, solange ich die 150 Pixel im Code stehen habe. Aber durch was soll ich sie ersetzen? :?

Mit dem "overflow: auto;" (siehe Zeile 5) sieht mein Code jetzt so aus ...

Code: Alles auswählen

<style>
#accordion .item {
    width: 698px;
    height: 30px; /* This is the height of the gray portion of each section */
    overflow: auto;
    transition: height ease-in-out 1000ms; /* This is the bit that makes the slider...slide */
    -o-transition: height ease-in-out 1000ms;
    -moz-transition: height ease-in-out 1000ms;
    -webkit-transition: height ease-in-out 1000ms;
    border: 1px solid #ccc;  /* This sets the color and width of the border */
    border-radius: 5px;  /* This sets the roundness of the border corners */
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    margin-bottom: 5px;
}
#accordion a {
    display: block;
    height: 20px;
    line-height: 20px;
	background: #eeeeee; /* This is for all the old browsers */
	background: -moz-linear-gradient(top, #1fc213 0%, #178110 100%); /* This gradient is for firefox */
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(100%,#cccccc)); /* This one is for webkit browsers */
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#cccccc',GradientType=0 ); /* and of course we musn't forget ie */
    padding: 5px;
    color: #ffffff;  /* This and the next few lines sets the font up for the header on each box */
    text-decoration: none;
    font-family: Georgia, Arial, Tahoma, sans-serif;
}
#accordion p {
    height: 150px;  /* This and the next few lines sets the font up for the content of each box */
    padding: 5px;
    font-family: Georgia, Arial, Tahoma, sans-serif;
    font-size: 13px;
}
#accordion div:hover {
    height: 150px; /* This is the total height when the scroll unfolds see the 150px in the element above */
    
}
#accordion div:hover a {
    border-bottom: 1px solid #cccccc;
}
</style>

<div id="accordion">
  <div class="item">
        <a href="#">Products</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam.</p>
    </div>
    <div class="item">
<a href="#">Services</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
    </div>
    <div class="item">
<a href="#">Contact</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam.</p>
    </div>
    <div class="item">
<a href="#">Support</a>
        <p>Lorem ipsum nec ex prompta tractatos. Ea elit sale admodum vim, at velit nemore rationibus per. Ullum qualisque dissentias ei qui, in putent doctus cotidieque mei. Mel legere mucius ne, adhuc impetus signiferumque cu eos. Has an zzril soluta impetus. An nisl graece inciderint nec, ea per rebum animal, prodesset accommodare ex eam.</p>
    </div>
</div>

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: Mo 29. Dez 2014, 13:14
von npage-user
Jetzt habe ich den Inhalt so einstellen können, dass es immer auf die korrekte Höhe ausfährt. Allerdings ist jetzt der Slide-Effekkt nicht mehr vorhanden. Irgendwie schließt das eine immer das andere aus ...

http://www.holidaypark-uptodate.de/akkordeon-test.html

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: Do 1. Jan 2015, 18:26
von moni
npage-user hat geschrieben:Jetzt habe ich den Inhalt so einstellen können, dass es immer auf die korrekte Höhe ausfährt. Allerdings ist jetzt der Slide-Effekkt nicht mehr vorhanden. Irgendwie schließt das eine immer das andere aus ...

http://www.holidaypark-uptodate.de/akkordeon-test.html
Es ist ja schade weil sehr schöne leiste ist, und das ganze zittert ein wenig was nicht so optimal ausseht :E :E hast schon probiert und komplett die div hover angaben weggemacht ?
Meistens ist auch so :das so lange keine extra " height" angaben vorhanden sind da passt sich die Höhe automatisch aus .. :E

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: Fr 2. Jan 2015, 18:19
von npage-user
moni hat geschrieben:Es ist ja schade weil sehr schöne leiste ist, und das ganze zittert ein wenig was nicht so optimal ausseht :E :E hast schon probiert und komplett die div hover angaben weggemacht ?
Meistens ist auch so :das so lange keine extra " height" angaben vorhanden sind da passt sich die Höhe automatisch aus .. :E
Wenn ich die Hover-Angaben entferne, dann breitet sich die Leiste gar nicht nach unten aus.

Aber ich habe eine andere Lösung gefunden. Die ist zwar etwas schreibaufwändiger, funktioniert aber auch: Da ich ja nur eine bestimmte Anzahl verschiedener Höhen brauche, habe ich in einem Stylesheet einfach Hover-Menüs unter verschiedenen Angaben angelegt (im jetzigen Fall für eine Umfrage mit 3, 4, 5 oder 6 Antworten). Siehe auch hier: http://www.holidaypark-uptodate.de/akkordeon.html :)

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: Fr 2. Jan 2015, 21:08
von moni
Das sieht schon jetzt sehr gut aus ..sehr schön gemacht !!!

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: Sa 3. Jan 2015, 01:55
von thaileben
sieht echt klasse aus du hast wirklich immer wieder gute einfälle
im FF funktioniert sie hervorragend

Jürg :X

Re: Akkordeon-Menü: verschiedene Höhen erzeugen

Verfasst: Sa 3. Jan 2015, 19:21
von sansiro
thaileben hat geschrieben:im FF funktioniert sie hervorragend

Jürg :X
Im IE siehts leider nicht so gut aus :(