Jump to content

Recommended Posts

The CSS is not working in all browsers.

 

HTML:

 

<div class="groupBox">
<div class="groupHeading">
Heading 1
</div>
<div class="group">
<div class="title-2">
<div class="catHeading">
Category 1
</div>
<div class="cateDescription">
This is category description 1
</div>
</div>
<div class="countTopics">
<b>Topic Count:</b><br>
<font>( 345 )</font>
</div>
<div class="clear"></div>
</div>
<div class="group">
<div class="title-2">
<div class="catHeading">
Category 2
</div>
<div class="cateDescription">
This is category description 2
</div>
</div>
<div class="countTopics">
<b>Topic Count:</b><br>
<font>( 545 )</font>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>

Link to comment
https://forums.phpfreaks.com/topic/271685-last-child/#findComment-1397926
Share on other sites

You don't have a group that is the last-child.  The last child of your groupBox element is:

<div class="clear"></div>

 

You could try :last-of-type instead, or just create another class to use that indicates the last one and add it to the element yourself.

 

Link to comment
https://forums.phpfreaks.com/topic/271685-last-child/#findComment-1397945
Share on other sites

Okay... :last-of-type doesn't even exist...

 

sure it does, and it has decent support.  However, it doesn't appear to be useful in your situation because it doesn't take the class name into consideration so it still considers the <div class="clear"> element to be the last.

 

If you need IE7 support, your best bet is making your own class to represent the last element.  eg:

<div class="groups">
  <div class="group"></div>
  <div class="group"></div>
  <div class="group last"></div>
</div>

 

.groups {
    display: block;
    border: 1px solid yellow;
    padding: 10px;
    width: 300px;
}
.group {
    display: block;
    border: 1px solid red;
    background: black;
    width: 100px;
    height: 100px;
    margin: 10px;
}
.group.last {
    background: white;
    border: 1px solid black;
}

 

Link to comment
https://forums.phpfreaks.com/topic/271685-last-child/#findComment-1397995
Share on other sites

that just makes it more difficult lol.

 

Such are the ways of the webdesigner.  The more browsers you want to support, the harder it's going to be for you.

 

after i have the design done im putting the category html inside a while loop, making the .group .last element useless unless i use JS (which im trying to avoid so far so good).

 

You don't need JS just to identify the last one.  I assume by putting it in a while loop you mean using PHP or some other server language.  Just use a variable to identify the last iteration of your while loop and add the last class when you generate the html.  

 

 

Link to comment
https://forums.phpfreaks.com/topic/271685-last-child/#findComment-1398042
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.