Ergebnis 1 bis 9 von 9

Thema: Hilfe mit Javascript - Content ein und aus blenden

  1. #1
    TP-Junior
    Registriert seit
    Jun 2012
    Beiträge
    6

    Hilfe mit Javascript - Content ein und aus blenden

    Hallo Com,

    ich bin derzeit am basteln einer Homepage und jetzt geht es an den Feinschliff

    Ich habe eine News Seite gebaut auf der wie ja der Name schon sagt Neuigkeiten zu sehen sind. Aber wenn der User jetzt auf diese Seite geht, soll er nicht die vollständigen News sehen sondern nur einige Wörter, zum vollständigen lesen soll er auf Pfeile klicken die dann den ganzen content ausklappen. Natürlich sollen sich die News auch wieder einklappen lassen können und was auch sehr schön wäre, wenn man eine News offen hat und eine zweite aufmacht, die erste sich selbst schließt (also nur immer eine Neuigkeit offen sein kann )

    Ich bin derzeit auf diesem stand:

    HTML-Code:
    <html>
    	<head>
    		<title>Test</title>
    		<style>
    			#content{
    				position: relative;
    				width: 370px;
    				padding: 5px;	
    				border-right: 2px solid #D8D8D8;
    				height: 120px;
    				overflow: hidden;
    			}
    			#arrows {
    				position: relative;
    				width: 11px;
    				height: 14px;
    				border: 0px;
    				background-image: url(up.png);
    			}
    		</style>
    		<script type="text/javascript">
    			function Overflow () {
    				document.all.content.style.height = "auto";
    				document.all.arrows.style.backgroundImage = "url(down.png)";
    				document.getElementById("arrowlink").href = "javascript:Underflow()";
    			}
    			function Underflow () {
    				document.all.content.style.height = "120px";
    				document.all.arrows.style.backgroundImage = "url(up.png)";
    				document.getElementById("arrowlink").href = "javascript:Overflow()";
    			}
    			
    		</script>
    	</head>
    	<body>	
    		<a id="arrowlink"  href="javascript:Overflow()"><img alt="up" id="arrows"></img></a>
    		<div id="content">
    			<h3>Neuigkeit - New</h3>
    			<h5>09.06.2012</h5>
    			<p>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.</p>
    		</div>
    	</body>
    </html>
    aber so richtig gefällt mir die methode auch nicht :/

    Vielleicht kann mir ja einer von euch weiterhelfen...
    Ich wäre sehr dankbar!

    Schonmal jetzt DANKE für eure Hilfe! Ich hoffe ich hab mich klar genug ausgedrückt, falls nicht kann ich auch noch schnell ein paar Screenshoots machen!

    Danke,
    wuaschtsalod

  2. #2
    TP-Senior Avatar von PascalKremp
    Registriert seit
    Apr 2012
    Ort
    Wuppertal
    Beiträge
    237
    Hi wuaschtsalod,

    magst du vielleicht genauer beschreiben, wie du es haben möchtest?

    So etwas in der Art? http://jsfiddle.net/3RhWq/ (Oben auf Run klicken)

    Gruß

  3. #3
    TP-Junior
    Registriert seit
    Jun 2012
    Beiträge
    6
    Danke schon mal für deine schnelle Antwort!

    Ja vom Prinzip stimmt es.

    IST - Zustand:
    Beitrag lässt sich mit den Pfeilen ausklappen und wieder einklappen.
    Leider funktioniert das nur solange wie die ID nur einmal vergeben ist...

    SOLL - Zustand:
    Jeder Beitrag soll ausgeklappt bzw. wieder eingeklappt werden können, ist aber ein Beitrag aktiv (ausgeklappt) soll dieser erst eingeklappt werden, bevor der zweite Ausgeklappt wird.

    Ich hoffe man versteht es jetzt besser, ich werde noch kurz ein Bild machen, damit man es besser erkennen kann wovon ich rede.

    Danke und Gruß

    Hier noch kurz das Bild:
    Name:  sollzustand.png
Hits: 87
Größe:  45,8 KB
    Geändert von wuaschtsalod (16.06.2012 um 21:33 Uhr) Grund: Bild hinzugefügt

  4. #4
    TP-Senior Avatar von PascalKremp
    Registriert seit
    Apr 2012
    Ort
    Wuppertal
    Beiträge
    237
    Sorry, habe erst jetzt deine Antwort gelesen.
    Wenn du noch zu keiner Lösung gekommen bist: eine Lösung http://jsfiddle.net/8jVbJ/

  5. #5
    TP-Junior
    Registriert seit
    Jun 2012
    Beiträge
    6
    Hallo Pascal,
    ein rießiges DANKESCHÖN an dich! Das ist genau das was ich gesucht habe, aber leider bekomme ich es irgendwie nicht so recht hin einzubauen, ich glaube ich mach irgendwas falsch oder steh gerade einfach nur auf dem Schlauch?!

    Ich habe mir, da ja jQuery den jQuery 1.7.2 Codepack da runtergeladen und in meine HTML-Datei importiert, dann habe ich noch den Code von dir, heißt CSS + Javascript + HTML integriert. Angezeigt wird zwar dann alles, aber irgendwie kann ich dann nix machen :/

    Wäre toll wenn du mir noch ein letztes mal helfen könntest!

    Danke schon einmal,
    schöne Grüße!

  6. #6
    TP-Senior Avatar von PascalKremp
    Registriert seit
    Apr 2012
    Ort
    Wuppertal
    Beiträge
    237
    Gerne helfe ich auch noch drei mal

    Hast du darauf geachtet, dass Klassen im JavaScript, CSS und HTML gleich heißen?
    Hast du jQuery importiert bevor du mein Script aufrufst?

    Zeig mir bitte deinen Quelltext, wenn die 2 Fragen dir noch geholfen haben.

    Gruß

  7. #7
    TP-Junior
    Registriert seit
    Jun 2012
    Beiträge
    6
    Ich habe es dann sogar mit Copy + Paste versucht, was leider auch nicht geklappt hat...

    Hier mal mein letzes Ergebnis:

    Nicht erschrecken, ich habe den unnötigen Code (wie Header und Menü) mal rausgelassen:

    Code:
    html{
    	font: 14px Arial, sans-serif;
    }
    h1{
    	font: 36px "Trebuchet MS", Georgia, serif;
    	font-weight: bold;
    	color: #B90000;
    	margin: 0px 0px 5px 0px;
    	text-align: center;
    	border-bottom: 1px solid #D8D8D8;
    }
    #wrapper{
    	position: relative;
    	width: 1000px;
    	left: 50%;
    	margin-top: 30px;
    	margin-left: -500px;
    	margin-bottom: 25px;
    	min-height: 800px;
    	padding: 25px;
    	border: 2px solid #FFFFFF;
    	box-shadow: 0 0 10px #999999;
    	background-color: #EFEFEF;
    	border-radius: 15px;
    }
    #headline{
    	position: relative;
    	width: 770px;
    	height: 75px;
    	left: 50%;
    	margin-left: -385px;
    	margin-top: 30px;
    }
    #content{
    	position: relative;
    	width: 1000px;
    	min-height: 700px;
    	overflow:auto;
    	left: 50%;
    	margin-left: -500px;
    }
    #content_right{
    	position: relative;
    	float: left;
    	width: 770px;
    	margin-left: 20px;
    }
    #content_left_line {
    	position: relative;
    	float: left;
    	width: 370px;
    	padding: 5px;	
    	border-right: 2px solid #D8D8D8;
    	height: 110px;
    	overflow: hidden;
    }
    #content_right_line {
    	position: relative;
    	margin-left: 380px;
    	border-left: 2px solid #D8D8D8;
    	float: left;
    	width: 370px;
    	padding: 5px;
    	text-align: left;
    	height: 110px;
    	overflow: hidden;
    }
    /*Javascript (News)*/
    article {
        padding:1em;
        margin:1em;
        box-shadow:0px 2px 3px rgba(0,0,0,0.65);
    }
    .entry-content {
        height:75px;
        overflow:hidden;
        opacity:0.5;
    }
    .entry-content.full {
        height:auto;
        opacity:1;
    }
    header {
        border-bottom:1px solid #cccccc;
        margin-bottom:0.25em;
        padding-bottom:0.25em;   
        position:relative;
        cursor:pointer;
    }
    header a {
        position:absolute;
        top:0;
        right:10px;
        font-weight:bold;
        text-decoration:none;
        color:blue;
        -webkit-transform: rotate(90deg);
        -moz-transform: rotate(90deg);
    }
    
    .less {
        -webkit-transform: rotate(-90deg);
        -moz-transform: rotate(-90deg);    
    }
    HTML-Code:
    <html>
    	<head>
    		<link href="inc/style.css" rel="stylesheet" type="text/css">
    		<script src="inc/jquery.js"></script>
    		<script>
    			(function($) {
    				allArticlesContent = $('.entry-content');
    				arrows = $('article header a');
    				$('header').on('click', function(e) {
    					self = $(this);
    					content = self.parent('article').find('.entry-content');
    					arrow = self.find('a');
    					contentHeight = content.height();        
    					
    					if (content.hasClass('full')) {
    						content.toggleClass('full');
    						arrow.toggleClass('less');        
    					} else {
    						arrows.removeClass('less');
    						allArticlesContent.removeClass('full');            
    						content.addClass('full');
    						arrow.addClass('less');            
    					}
    					
    					e.preventDefault();
    				});
    			})(jQuery);
    		</script>
    	</head>
    	
    	<body>
    		<div id="wrapper">
    			<div id="content">
    				<div id="content_right">
    					<div id="headline">
    						<h1>Neuigkeiten</h1>
    					</div>	
    					<div id="content_left_line">
    						<article>
    							<header>
    								<h1>Heading 2</h1>
    								<a href="#" class="more"> >> </a>
    							</header>
    							<div class="entry-content">
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    							</div>
    						</article>
    					</div>
    					<div id="content_right_line">
    						<article>
    							<header>
    								<h1>Heading 2</h1>
    								<a href="#" class="more"> >> </a>
    							</header>
    							<div class="entry-content">
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    							</div>
    						</article>
    					</div>
    					<div id="content_left_line">
    						<article>
    							<header>
    								<h1>Heading 2</h1>
    								<a href="#" class="more"> >> </a>
    							</header>
    							<div class="entry-content">
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    							</div>
    						</article>
    					</div>
    					<div id="content_right_line">
    						<article>
    							<header>
    								<h1>Heading 2</h1>
    								<a href="#" class="more"> >> </a>
    							</header>
    							<div class="entry-content">
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    								<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    								tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    								quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    								consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    								cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    								proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    							</div>
    						</article>
    					</div>					
    				</div>
    			</div>
    		</div>
    	</body>
    </html>
    Ich hoffe es ist nicht all zu viel Aufwand für dich!
    Auf alle Fälle noch einmal Danke für deine Mühen!

    Gruß

  8. #8
    TP-Senior Avatar von PascalKremp
    Registriert seit
    Apr 2012
    Ort
    Wuppertal
    Beiträge
    237
    Hi,

    1. Lade Javascript vor dem schließenden Body-Tag
    2. Recherchiere, wann man Klassen und wann man IDs benutzt
    3. Deine Elemente mit der ID #content_left_line und #content_right_line haben eine gesetzte Höhe und overflow: hidden; Daraus folgt, wenn Elemente darin größer werden, merkst du davon nichts.

    In meinem Blog erkläre ich, wie man heutzutage HTML & CSS lernen sollte. Das solltest du dir mal genau angucken.

  9. #9
    TP-Junior
    Registriert seit
    Jun 2012
    Beiträge
    6
    Danke für deine zahlreichen Hilfestellungen jetzt funktioniert es
    Habe deine Punkte berücksichtigt und werde es dann auch gleich so beibehalten

    Bis dann, danke!
    Wuaschtsalod

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Ähnliche Themen

  1. [jQuery] per Ajax erzeugter Content - dort erneut Javascript ausführen
    Von alexf812 im Forum Javascript & Ajax
    Antworten: 1
    Letzter Beitrag: 23.03.2010, 21:54
  2. Hilfe bei Daz3d content installation in Poser7
    Von Irina1979 im Forum Sonstige Programme
    Antworten: 1
    Letzter Beitrag: 09.02.2009, 08:07
  3. Hilfe: komische Kästen nach Content-Inhalt
    Von TheEkki im Forum TYPO3
    Antworten: 7
    Letzter Beitrag: 02.08.2007, 14:20
  4. Hilfe! Content Links Typo3 mit Templavoila
    Von d-design im Forum TYPO3
    Antworten: 4
    Letzter Beitrag: 10.05.2006, 16:28
  5. Content-Scrolling mit Javascript einbauen
    Von phoebe111 im Forum GoLive
    Antworten: 4
    Letzter Beitrag: 27.11.2005, 12:28

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

     

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51