HTML image and div resize -


.d1 {     background-color: red;     text-align: center; }  <div class="d1">     <img src="http://www.aliceseelywholesale.net/wp-content/uploads/adb101-daisy-cutout-narrow-link-bracelet-300x100.jpg"> </div> 

i use above simple code display image in middle div. code works when resize window below width of image, border/div doesn't cover image... there way fix this? ty

enter image description here

if want use backgound image <div> suggest set image background-image div, , remove <img> element.

this save using addition element , fix problem:

.d1 {      width:300px;      height:100px;      background-color: red;      text-align: center;      background-image: url(http://www.aliceseelywholesale.net/wp-content/uploads/adb101-daisy-cutout-narrow-link-bracelet-300x100.jpg);      background-size:cover;  }
<div class="d1">      </div>


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -