Jump to content

margin help


spires

Recommended Posts

Hi

 

I have an image, that is inside of an <a> tag, that is inside of a <div>

 

// CSS
#boxImgs a img {
	float: left;
	border:none;
	margin-right: 30px;	
}

// Script
                  <div id="boxImgs">
                      <a href="#"><img src="images/testimonials/play3.jpg" /></a>
                      <a href="#"><img src="images/testimonials/play4.jpg" /></a>
                      <a href="#"><img src="images/testimonials/houses.jpg" /></a>
                  </div>

 

I want all the images to have a right margin, except for the last image in the row.

 

 

Can I do something like the following?

 

// CSS
#boxImgs a img {
	float: left;
	border:none;
	margin-right: 30px;	
}
#boxImgs a img .noMargin {
	float: left;
	border:none;
	margin-right: 0px;	
}

// Script
                  <div id="boxImgs">
                      <a href="#"><img src="images/testimonials/play3.jpg" /></a>
                      <a href="#"><img src="images/testimonials/play4.jpg" /></a>
                      <a href="#" class="noMargin"><img src="images/testimonials/houses.jpg" /></a>
                  </div>

 

 

 

Thanks for your help :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/199401-margin-help/
Share on other sites

What if you just did this:

// CSS
#boxImgs a img {
      float: left;
      border:none;
      margin-right: 30px;   
}
.noMargin {
      float: left;
      border:none;
      margin-right: 0px;   
}

// Script
                  <div id="boxImgs">
                      <a href="#"><img src="images/testimonials/play3.jpg" /></a>
                      <a href="#"><img src="images/testimonials/play4.jpg" /></a>
                      <a href="#" class="noMargin"><img src="images/testimonials/houses.jpg" /></a>
                  </div>

Link to comment
https://forums.phpfreaks.com/topic/199401-margin-help/#findComment-1046529
Share on other sites

Oh, I just realized something. You have the class tag on your <a>, not your image. Try one of these:

// CSS
#boxImgs a img {
      float: left;
      border:none;
      margin-right: 30px;   
}
#boxImgs a .noMargin {
      float: left;
      border:none;
      margin-right: 0px;   
}

// Script
                  <div id="boxImgs">
                      <a href="#"><img src="images/testimonials/play3.jpg" /></a>
                      <a href="#"><img src="images/testimonials/play4.jpg" /></a>
                      <a href="#" class="noMargin"><img src="images/testimonials/houses.jpg" /></a>
                  </div>

 

Or:

// CSS
#boxImgs a img {
      float: left;
      border:none;
      margin-right: 30px;   
}
#boxImgs a img .noMargin {
      float: left;
      border:none;
      margin-right: 0px;   
}

// Script
                  <div id="boxImgs">
                      <a href="#"><img src="images/testimonials/play3.jpg" /></a>
                      <a href="#"><img src="images/testimonials/play4.jpg" /></a>
                      <a href="#"><img class="noMargin" src="images/testimonials/houses.jpg" /></a>
                  </div>

 

Link to comment
https://forums.phpfreaks.com/topic/199401-margin-help/#findComment-1046535
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.