Ich hatte ein Quiz in einer HTML/CSS-Klasse, die ich nehme, um Medienanfragen zu verwenden, um einige divs basierend auf der Bildschirmgröße zu reorganisieren. Der Code, den sie geliefert, dass ich angeblich auf hinzuzufügen, war dies:Bestellung von CSS in einem style-Tag
<style type="text/css">
/*
These are the responsive styles. Throw some breakpoints in here!
*/
.container {
display: flex;
flex-wrap: wrap;
}
.box {
width: 100%;
}
@media screen and (max-width: 400px) {
.dark_blue {
color: blue;
}
}
</style>
Es gab viel mehr als das, aber das ist der relevante Teil. Ich kam mit diesem:
<style type="text/css">
/*
These are the responsive styles. Throw some breakpoints in here!
*/
@media screen and (min-width: 450px) {
.light_blue, .green {
width: 50%;
}
}
@media screen and (min-width: 550px) {
.red {
width: 33.3%;
}
.orange {
width: 66.6%;
}
}
@media screen and (min-width: 800px) {
.container {
width: 800px;
margin-left: auto;
margin-right: auto;
}
}
.container {
display: flex;
flex-wrap: wrap;
}
.box {
width: 100%;
}
@media screen and (max-width: 400px) {
.dark_blue {
color: blue;
}
}
</style>
Aber es tat buchstäblich nichts. Die Seite war komplett unverändert. Ich gab schließlich auf und sah die Antwort, hatte sie geschrieben genau das gleiche, die CSS, die ich hatte, nur in einer anderen Reihenfolge:
<style type="text/css">
/*
These are the responsive styles. Throw some breakpoints in here!
*/
.container {
display: flex;
flex-wrap: wrap;
}
.box {
width: 100%;
}
@media screen and (min-width: 450px) {
.light_blue, .green {
width: 50%;
}
}
@media screen and (min-width: 550px) {
.red {
width: 33.3%;
}
.orange {
width: 66.6%;
}
}
@media screen and (min-width: 800px) {
.container {
width: 800px;
margin-left: auto;
margin-right: auto;
}
}
@media screen and (max-width: 400px) {
.dark_blue {
color: blue;
}
}
</style>
Also meine Frage ist, wie kommt angewendet, um hier und warum didn‘ t mein Code überhaupt etwas tun?
was Sie versuchen möchten? poste etwas html und erkläre etwas mehr, damit wir dir auf die richtige Weise helfen können .. –