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
Share on other sites

Yes, I've tested it.

But it does not work.

 

I think the order might be incorrect:

#boxImgs a img .noMargin {

 

 

as the class is apart of the <a> tag, maybe something like:

#boxImgs a .noMargin img {

 

but that does not work either.

 

Any ideas would be great  :)

 

 

Link to comment
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.