Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
targeting the first post in a topic
Avatar
Shane Stegeman
Member
Free Members
sp_UserOfflineSmall Offline
May 15, 2016 - 9:52 am

Hi again Simple Press team

 

Just another question 

When a user creates a topic, they generally ask a question which shows up at the top and then other people answer the first person's question. Is there a way I can target the first post inside a topic to have it styled differently to all the subsequent posts? I  want to emphasize the first post in the topic as that is the primary focus.This is with css ofcourse.

 

Your help as always is appreciated.

Avatar
Ike
Sawtry, UK
Member
Free Members
sp_UserOfflineSmall Offline
May 15, 2016 - 10:44 am

hey Shane,

I'm fairly sure you have a child theme set up, at least if you don't yet I've posted the instructions in your other topic.

You can target the CSS within the first post using the class 'spFirstPost'.

For example, using it like this will make the background of the first post in every topic red:

#spMainContainer .spFirstPost {
    background: red;
}

You can use it more precisely by using 'spFirstPost' before targeting elements within the post, for example this will make the post content background within the first post in every topic red:

#spMainContainer .spFirstPost .spPostContentSection .spPostContent {
    background: red;
}

Assuming here that you know basic CSS you can change that 'background: red;' for whatever you'd like that's applicable to the element you're editing. As long as 'spFirstPost' is used any subsequent post specific rules will only apply to the first post.

Hope that helps!

Avatar
Shane Stegeman
Member
Free Members
sp_UserOfflineSmall Offline
May 16, 2016 - 8:13 am

Thanks Ike. I will give that a go!

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 16, 2016 - 8:45 am

Let us know how it goes...

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 649
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 618
Members: 17348
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10120
Posts: 79607