2016-05-20 11 views
0

Ich habe ein Problem mit Float. Der Text fließt nicht das Bild von der rechten Seite mit Ausnahme der ersten Zeile. Wenn ich ein neues HTML-Dokument erstellen und ein Bild mit Beschreibung einfügen, funktioniert alles einwandfrei. Ich weiß nicht, wo das Problem liegt.Float-Eigenschaft funktioniert nicht

Hier ist der html:

<div id="container"> 

    <div id="logo"> 
     <h1>Best movies of all time!</h1> 
    </div> 

    <div id="nav"> 
     Shawshank Redemption <br /> 
     Forrest Gump <br /> 
     Seven <br /> 
     The Lord of the Rings <br /> 
     American Gangster <br /> 
    </div> 

    <div id="content"> 

     <h2>Shawshank Redemption</h2> 

     <p id="shawshank_description"> 
     <img id="shwashank" src="img/shawshank.jpg" width="200" height="150" /> 
     The Shawshank Redemption is a 1994 American drama film written and directed by Frank Darabont, and starring Tim Robbins and Morgan Freeman. Adapted from the Stephen King novella Rita Hayworth and Shawshank Redemption, the film tells the story of Andy Dufresne, a banker who is sentenced to life in Shawshank State Penitentiary for the murder of his wife and her lover, despite his claims of innocence. During his time at the prison, he befriends a fellow inmate, Ellis Boyd "Red" Redding, and finds himself protected by the guards after the warden begins using him in his money-laundering operation. Although it was a box office disappointment, the film received multiple award nominations (including seven Oscar nominations) and outstanding reviews from critics for its acting, story, and realism. It has since been successful on cable television, VHS, DVD, and Blu-ray. It was included in the American Film Institute's 100 Years...100 Movies 10th Anniversary Edition.[4] It is considered to be one of the greatest films of all time. The Shawshank Redemption is a 1994 American drama film written and directed by Frank Darabont, and starring Tim Robbins and Morgan Freeman. Adapted from the Stephen King novella Rita Hayworth and Shawshank Redemption, the film tells the story of Andy Dufresne, a banker who is sentenced to life in Shawshank State Penitentiary for the murder of his wife and her lover, despite his claims of innocence. 
     </p> 

    </div> 

    <div id="ad"> 
     <img src="img/banner.gif" /> 
    </div> 

    <div id="footer"> 
     Best movies of all time! &copy; All rights reserved 
    </div> 

</div> 

Hier ist die CSS:

#shawshank { 
    float: left; 
} 
+0

Sie sollten Chrom Entwickler-Tools verwenden Sie eine bessere Vorstellung davon zu geben, was CSS-Stile – Maxwelll

Antwort

0

Das Problem hier ist, dass Ihr float: left Styling ist dies nicht angewendet ... Versuchen:

HTML:

<p id="shawshank_description"> 
    <div class="shank_image"> 
    <img src="img/shawshank.jpg" width="200" height="150" /> 
    </div> 
    It is considered to be one of the greatest films of all time... 
</p> 

CSS:

.shank_image img{ 
    float: left; 
} 

https://jsfiddle.net/qbbbm514/

+0

Ihre Lösung funktioniert angewendet werden. Vielen Dank. Aber weißt du was, ich habe mal wieder versucht meinen Code zu benutzen und es funktioniert .... Ich verstehe nicht wirklich warum 'float: left' Styling nicht zum ersten Mal angewendet wurde. –

0

in Ihrer CSS-Datei, müssen Sie #shawshank {...} statt nur shawshank{...}, da Sie ein Element durch seine ID zielen. Auch habe ich in Ihrem Code festgestellt, dass die ID-Eigenschaft auf Ihrem Bild "Shwashank" statt "Shawshank" ist, so dass dies auch ein Problem sein könnte.

Auch Ihre Floats funktionieren möglicherweise nicht mit Ihrer aktuellen Verschachtelung des Bildes innerhalb des Absatz-Tags, da sie nebeneinander schweben sollen. Versuchen:

<img id="shawshank" src="img/shawshank.jpg" width="200" height="150" /> 
<p id="shawshank_description">...</p> 

Und in der CSS-Datei hinzufügen:

#shawshank_description { 
    float: right; 
} 
Verwandte Themen