Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

CSS How do I only show the first element using css

rajc08

Coder
I want to be able to ONLY show the first "in-conversation-wistia" div element so that the second one with the same class name is hidden. I tried doing this using the below code but didn't work and gets both of the div elements.

I used the below code to achieve this but it did not work.

HTML:
.in-conversation-wistia {
  display:none;
}

.in-conversation-wistia:nth-child(1) {
    diaplay:block;
}

See the screenshot, the yellow highlighted is the only one I want to show

Thanks,

Raj
 

Attachments

  • Capture.PNG
    Capture.PNG
    40.8 KB · Views: 3
First hide all your .in-conversation-wistia class and put the .show class in that element which you want to show. There is already a class named .show.
 
the .show class only has a "display:block" and in-conversation-wistia is just an empty class as I am differentiating it from conflicting with other classes which were called "wistisa"
 
See the video(zip attached). If this is what you want than add the below code in your production.css file below body class(line 280)-
CSS:
.c-video-section-wrap{
    display:none;
}
.show{
    display:block;
}
And add show class in your html file(line 738)-
HTML:
<div class="c-video-section-wrap c-video-section-wrap--bg-color t-ime show">
 

Attachments

  • Test.zip
    6.7 MB · Views: 1
See the video(zip attached). If this is what you want than add the below code in your production.css file below body class(line 280)-
CSS:
.c-video-section-wrap{
    display:none;
}
.show{
    display:block;
}
And add show class in your html file(line 738)-
HTML:
<div class="c-video-section-wrap c-video-section-wrap--bg-color t-ime show">
Thanks for you help but the show class is only toggled using jquery when the link for it is clicked. by default I need all "in-conversation-wistia" hidden apart from the first one. Then when you toggle each one, it will add a class of "show" and class of "hide" to others so that only one video is showing at any one time. Does that make sense?
 
In that case don't put the show class in html. Than nothing will be visible.
but I need the first video to show otherwise it will be a blank page lol. All I need is the yellow highighted but to show without the other ones showing . Make sense? I hope you can help, because you're so close to a solution. I have tried and can't work it out
 
im sorry! lol. so you are manually addding it in css. My video is being generated via php in a forloop so I can't hardcode the the "show" class specifically to it hence, I need to show the FIRST video only out the three and then use Jquery or javascript to toggle the "show" class so that each time, only one video is being showed when you click the chapters on the left hand side on the page
 
Pretty sure you can use "first-of-type" selector in CSS to make sure the first in-conversation-wistia in your main 'section' is shown while others are not.

Glad you solved it though. For future, look into first-of-type, first-child, etc.
 
Back
Top Bottom