[HTML] Wie kann ich das fixieren?

7 Antworten

HTML:

<div class="container">
  <div class="box">
    <!-- long text comes here... -->
  </div>
  <div class="box--fixed">
    <!-- fixed sub-text comes here... -->
  </div>
</div>

CSS:

.container {
  width: 100%;
  max-width: 1170px;
  margin: 0 auto
}

.box {
  width: 80%
}

.box--fixed {
  width: 20%; 
  position: fixed; 
  z-index: 500; 
  top: 0px;
  right: 0px
}

LG medmonk

Woher ich das weiß:Berufserfahrung

Was das rote Feld angeht, einfach position: absolute; machen und dann mit (top, left, right width, height...) Position und Größe festlegen. Den Text einfach in eine Div schreiben, der ne ID zuweisen und darüber dann Position festlegen. Wenn du noch einen Rahmen haben will, dann mit Border arbeiten.

Woher ich das weiß:Studium / Ausbildung

Mit position: absolut wird der Text absolut positioniert, bei position: fixed würde der Text beim scrollen immer auf der Viewport Höhe bleiben je nachdem was du eher willst.

Woher ich das weiß:Studium / Ausbildung

per css

#text2

{

Position:Fixed;

}

Woher ich das weiß:Hobby – Viele YouTube Tutorials