Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi,

 

ich habe eine div, in der ein Bild eingebettet ist und

ich möchte, dass wenn ich über die div oder dem Bild mit der Maus "Hoover",

dass ein Text in der Div sichtbar wird. 

 

Außerdem möchte ich das Bild generell vertikal und horizontal in der div zentrieren. Das klappt auch noch nicht so ganz. 

Wäre für Hilfe sehr dankbar!

 

Das hier funktioniert, aber nicht so wie oben beschrieben: 

 

 

HTML:

 

       <div id="div_pic01">
           <a href="www.google.de"> 
               <img  src="1.jpg" alt="alternativer_text">
           </a>  
           <p id="text_pic01">Angezeigter Text in der Mitte der div</p>
       </div>

 

 

CSS: 

 

#div_pic01{
  text-align: left;
  margin: 0 auto; 
  overflow: hidden; 
  border:0px solid black;
  width: 60%;
  height: 200px;
  min-width: 300px;
}

#div_pic01 a img{
    width: 100%;
    position: relative;
    top: -100%;    
}

#text_pic01{  
    position: relative;
    top: 50%;
    left:50%;
    visibility:hidden
}

#div_pic01:hover .text_pic01{
   visibility:visible;   
}

 

Bearbeitet von Kickflip

  • 5 Monate später...

Falls es dir jetzt noch was hilft, mir ist gerade zu deinem Einblenden etwas aufgefallen.

Zum einen hast du im CSS-Teil beim Hover "text_pic01" als Klasse aufgerufen, aber oben als ID/Element erstellt. Wenn du anstatt dem Punkt ein Hashtag verwendest, bist du schonmal einen Schritt weiter.

Außerdem würde ich die Position vom Text absolute setzen, damit sie auch das Bild verdecken kann und die des div auf relative.

Hier noch mein CSS-Teil, mit dem es bei mir geht. 

#div_pic01{
  text-align: center;
  position: relative;
  margin: 0 auto; 
  overflow: hidden; 
  border:0px solid black;
  width: 60%;
  height: 200px;
  min-width: 300px;
}

#div_pic01 a img{
    width: 100%;
    position: relative;
    top: -100%;    
}

#text_pic01{  
    position: absolute;
    top: 50%;
    left:50%;
    visibility:hidden;
}

#div_pic01:hover #text_pic01{
   visibility:visible;   

 

  • 2 Monate später...

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.