2016-04-05 9 views
0

Ich versuche mit "Fluid Layers" zu spielen und wenn ich die Größe des Fensters ändere (manuelle Größenänderung), möchte ich folgendes machen: display: none auf einem der Divs aber es scheitert zu tun (funktioniert einfach nicht).Liquid Layers - Anzeige: keine funktioniert nicht

Können Sie mir sagen, warum Display: keine Zeile 18 funktioniert nicht ?. Und zusätzlich, sollte ich DIVS verwenden, wenn ich 3 Blöcke in einem Container zentrieren möchte? oder hast du eine bessere Idee für mich?

Wäre glücklich, eine bessere/andere Ideen der Implementierung von Liquid Layers zu bekommen, wenn Sie irgendwelche wissen. Danke für Ihre Hilfe.

Hier ist mein Code:

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<style> 
body 
{ 
    background-color: #FFFFFF; 
} 

/* Extra small devices (phones, up to 480px) */ 
@media (max-width: 480px) 
{ 
    body 
    { 
    background-color: #FFFFFF; 
    } 
    .col3 { display: none; } 
} 

/* Extra small devices (usually phones from 480px to 768px) */ 
@media (min-width: 481px) and (max-width: 767px) 
{ 
    body 
    { 
    background-color: yellow; 
    } 
} 

/* Small devices (tablets, 768px and up) */ 
@media (min-width: 768px) and (max-width: 991px) 
{ 
    body 
    { 
    background-color: #444; 
    } 
} 

/* Small devices (tablets/desktop, 768px and up) */ 
@media (min-width: 992px) and (max-width: 1199px) 
{ 
    body 
    { 
    background-color: green; 
    } 
} 

/* large desktops and up ----------- */ 
@media (min-width: 1200px) 
{ 
    body 
    { 
    background-color: lightblue; 
    } 
} 
</style> 
</head> 
<body> 

<div style="width:100%; margin-left: 0 auto; background-color:#422220; text-align:center; overflow: hidden; padding:10px 0px;"> 
<div id="col1" style="width:29%; padding: 0; margin-left: 3%; margin-right:3%; background-color:#FFF333; display: inline- block">Text</div> 
<div id="col2" style="width:29%; padding: 0; margin-right:3%; background-color:#FFF333; display: inline-block">Text</div> 
<div id="col3" style="width:29%; padding: 0; margin-right:3%; background-color:#FFF333; display: inline-block">Text</div> 
</div> 

</body> 
</html> 
+2

Zeile 18, die Sie verwenden 'col3' als Klasse statt id, versuchen '# col3 {display: none; } '- https://jsfiddle.net/4uknmLe2/1/ – ASR

Antwort

0

Sie verwendet eine Klasse anstelle einer ID als Selektor.

Auch ich habe den allgemeinen Stil für alle Spalten in das Stylesheet anstatt in den Inline-Stil verschoben, wie Sie es taten.

body { 
 
    background-color: #FFFFFF; 
 
} 
 
#col1, 
 
#col2, 
 
#col3 { 
 
    width: 29%; 
 
    padding: 0; 
 
    margin-left: 3%; 
 
    margin-right: 3%; 
 
    background-color: #FFF333; 
 
    display: inline-block; 
 
} 
 
/* Extra small devices (phones, up to 480px) */ 
 

 
@media (max-width: 480px) { 
 
    body { 
 
    background-color: #FFFFFF; 
 
    } 
 
    #col3 { 
 
    display: none; 
 
    } 
 
} 
 
/* Extra small devices (usually phones from 480px to 768px) */ 
 

 
@media (min-width: 481px) and (max-width: 767px) { 
 
    body { 
 
    background-color: yellow; 
 
    } 
 
} 
 
/* Small devices (tablets, 768px and up) */ 
 

 
@media (min-width: 768px) and (max-width: 991px) { 
 
    body { 
 
    background-color: #444; 
 
    } 
 
} 
 
/* Small devices (tablets/desktop, 768px and up) */ 
 

 
@media (min-width: 992px) and (max-width: 1199px) { 
 
    body { 
 
    background-color: green; 
 
    } 
 
} 
 
/* large desktops and up ----------- */ 
 

 
@media (min-width: 1200px) { 
 
    body { 
 
    background-color: lightblue; 
 
    } 
 
}
<div style="width:100%; margin-left: 0 auto; background-color:#422220; text-align:center; overflow: hidden; padding:10px 0px;"> 
 
    <div id="col1">Text</div> 
 
    <div id="col2">Text</div> 
 
    <div id="col3">Text</div> 
 
</div>