2017-07-05 2 views
1

Ich habe versucht, p-Tag mit max-width-Attribut aber nicht für mich gearbeitet:Hinzufügen von Text unter jedem Bild in der Bildgalerie

.a { 
    max-width:100px; 
} 

Mit HTML:

<p class="a">Hello Welcome to Stackoverflow.</p> 

Ich will das Text soll unter dem Bild der Auflösung 500 * 500 passen. Wenn der Text mehr als die Bildbreite überschreitet, sollte er automatisch in die nächste Zeile eingefügt werden.

+0

Hallo Akash, begrüßen SO. Bitte nehmen Sie sich einen Moment Zeit, um Ihre Fragen zu beantworten: https://stackoverflow.com/help/how-to-ask – petezurich

Antwort

0

Ich weiß nicht, ist es das, was Sie brauchen, schauen Sie einfach diesen Schnipsel

.image_wrap { 
 
    width: 300px; 
 
} 
 
.image_wrap img { 
 
    width: 100%; 
 
}
<div class="image_wrap"> 
 
\t <img src="http://dreamicus.com/data/garden/garden-06.jpg" alt="garden" /> 
 
\t <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has</p> 
 
</div>

+1

yeah bro das ist was ich brauche Danke .... –

+0

Wenn das ist, was Sie brauchen, bitte kreuzen Sie an antworte als nützlich –

2

Verwenden Sie diesen Code

div { 
 
    height: auto; 
 
    width: 500px; 
 
} 
 

 
img { 
 
    height: 100%; 
 
    width: 100%; 
 
}
<html> 
 

 
<head> 
 

 
</head> 
 

 
<body> 
 

 
    <div> 
 
    <img src="img.jpg" /> 
 
    <p>Hello Welcome to Stackoverflow</p> 
 
    </div> 
 
</body> 
 

 

 

 
</html>

1

Sie c Versuchen Sie das. Es funktioniert gut für mich.

.resized_anchor { 
 
    \t max-width: 100px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
<title>question reality.</title> 
 
<link rel="stylesheet" type="text/css" href="style.css"> 
 
</head> 
 

 
<body> 
 
\t <div> 
 
\t \t <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSpMXZY5KMRLpo8vbVxizv5SiRdX2AXeM1lkT-7dXTL2D5el7UHZ59GHWc" height="100px" width="100px" /> 
 
\t \t <div class="resized_anchor"> 
 
\t \t \t <a href="#">Hello Welcome to Stackoverflow. Doing a greate job here</a> \t \t 
 
\t \t </div> 
 
\t </div> 
 
</body> 
 
</html>

Verwandte Themen