:nth-child selects more elements than expected [duplicate] - css

This question already has answers here:
What does the ">" (greater-than sign) CSS selector mean?
(8 answers)
What does a space mean in a CSS selector? i.e. What is the difference between .classA.classB and .classA .classB? [duplicate]
(3 answers)
Closed 3 years ago.
I have a html page with only one div that has a particular class:
<div class="article-page__wrapper article-page__article-content article-page--has-main-img">
Here is my selector which should only pick out one element under that div due to the nth-child attribute being 1.
.article-page__article-content :nth-child(1) {
background-color: red;
}
However, this is selecting numerous divs to give a red background.
Can anyone say why? Thanks!
Here's a sample of more html on the page, beneath the div with class article-page__article-content, where different divs have been reddened.
<div class="article-page__wrapper article-page__article-content article-page--has-main-img">
<div class="article-page__main-img-container">
<figure>
<img alt="2018." class="header-image" height="504" src="/media/images/30971178767_6a71936765_k.max-760x504.jpg" width="756">
<figcaption>
<div class="rich-text">wall, 2018.</div> | <div class="rich-text">Protection</div>
</figcaption>
</figure>
</div>
<div class="article-page__left-sidebar">
<div class="sidebar sidebar--share-article">
<h1 class="sidebar__heading">Share this</h1>
<ul class="sidebar__share-options-list">
<li>
<div class="icon-container">
<a href="https://twitter.com/intent/tweet?text=handout&url=http%3A//0.0.0.0%3A5000/en/handout/" aria-haspopup="false">
<svg role="img" class="icon icon-twitter" viewBox="0 0 50 50" width="50px" height="50px">
<title>Share on Twitter</title>
<use xlink:href="#icon-twitter" class="icon-style"></use>
</svg>
</a>
</div>
</li>
<li>
<div class="icon-container">
<a href="https://www.facebook.com/sharer.php?u=http%3A//0.0.0.0%3A5000/en/handout/" data-service="facebook" aria-haspopup="false">
<svg role="img" class="icon icon-facebook" viewBox="0 0 50 50" width="50px" height="50px">
<title>Share on Facebook</title>
<use xlink:href="#icon-facebook"></use>
</svg>
</a>
</div>
</li>
<li>
<div class="icon-container">
<a href="https://wa.me/?text=http%3A//0.0.0.0%3A5000/en/handout/?source=wa&medium=ar" data-service="whatsapp" aria-haspopup="false">
<svg role="img" class="icon icon-whatsapp" viewBox="-8 -8 50 50"" width="50px" height="50px">
<title>Share on WhatsApp</title>
<use xlink:href="#icon-whatsapp"></use>
</svg>
</a>
</div>
</li>
<li>
<div class="icon-container">
<a href="mailto:?&subject=handout&body=http%3A//0.0.0.0%3A5000/en/handout/" aria-haspopup="false">
<svg role="img" class="icon icon-email" viewBox="0 0 50 50" width="50px" height="50px">
<title>Share via email</title>
<use xlink:href="#icon-email"></use>
</svg>
</a>
</div>
</li>
<li>
<div class="icon-container">
<a href="#" class="share-link" aria-haspopup="false">
<svg role="img" class="icon icon-link" viewBox="0 0 50 50" width="50px" height="50px">
<title>Share link</title>
<use xlink:href="#icon-link"></use>
</svg>
</a>
</div>
</li>
</ul>
<span class="confirmation-text">URL copied to clipboard</span>
</div>
</div>
<div class="article-page__right-sidebar">
<div class="sidebar sidebar--newsletter">
<h1 class="sidebar__heading">Read more!</h1>
<p>Get our weekly email</p>
<div class="sidebar__form-container">
<form method="post" class="mailing-list__form" id="newsletter-signup" action="/api/newsetter-subscribe/">
<input type="hidden" name="list_id" value="17" id="newsletter-list_id">
<div class="single textinput sidebar__fieldset">
<label for="newsletter-email" class="is-required invisible-content">Enter your email address</label>
<input class="sidebar--newsletter__input" type="email" placeholder="Email address" name="newsletter-email" id="newsletter-email" />
<input class="sidebar--newsletter__input" type="text" placeholder="First name" name="newsletter-first-name" id="newsletter-first-name" />
<input class="sidebar--newsletter__input" type="text" placeholder="Last name" name="newsletter-last-name" id="newsletter-last-name" />
</div>
<div class="buttons sidebar__fieldset">
<button type="submit" class="btn">Submit</button>
</div>
</form>
</div>
</div>
</div>
<div class="article-page__rich-text">
<div class="rich-text"><p>Devil detail goes right here.</p><p>Have it love it get it right.</p><p></p><p>Good! Great.</p></div>
</div>
<div class="article-page__rich-text">
<div class="rich-text"><p>More text here.</p><p>Have it love it get it right.</p><p></p><p>Good! Great.</p></div>
</div>

Related

Why max width not working in tailwind css?

I have set max width to max-w-screen-2xl but the navbar is ignoring that and going outside the max width value. I have set max-w-screen-2xl for other sections and they are just workingfine. How to fix this?
<div className='flex items-center justify-center max-w-screen-2xl mx-auto'>
<div className="navbar nav-container bg-base-100 max-w-[90%] w-[90%] fixed top-3 z-50 px-8 py-6">
<div className="navbar-start">
<div className="dropdown">
<label tabIndex={0} className="btn btn-ghost lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M4 6h16M4 12h8m-8 6h16" /></svg>
</label>
</div>
<button onClick={()=>navigate('/')} className="btn btn-sm btn-ghost normal-case text-xl">daisyUi</button>
</div>
<div className="navbar-center hidden lg:flex">
<ul className="menu menu-horizontal p-0">
<li><a>Item 1</a></li>
<li><a>Item 3</a></li>
</ul>
</div>
<div className="navbar-end">
<button onClick={()=>navigate('/register')} className="btn btn-sm">Register</button>
</div>
</div>
</div>
after the percentage number, you need to determine the value from which to calculate the percentage. at this code
'''
max-w-[90%] w-[90%]
'''

Horizontal scrollbar not working when browser width is re-sized?

I have a div and within that i have divs with images in. what i want is for all the images to display but when the browser width is re-sized(smaller) for an automatic horizontal scrollbar to appear rather than the images stacking up below. I'm trying to create this but its not working. Any help??
<div style="height:80px;width:auto;border:1px solid red;white-space:nowrap;overflow-y:hidden;-ms-overflow-y:hidden;overflow-x:scroll;-ms-overflow-x:scroll;">
<div style="height:60px;width:90px;display:inline-block;">
<a href="#" >
<img style="max-height:60px;height:auto;max-width:90px;width:auto;margin:0 auto;padding:5px;display:inline-block;vertical-align:middle;" src="img1.png" />
</a>
</div>
<div style="height:60px;width:90px;display:inline-block;">
<a href="#" >
<img style="max-height:60px;height:auto;max-width:90px;width:auto;margin:0 auto;padding:5px;display:inline-block;vertical-align:middle;" src="img1.png" />
</a>
</div>
<div style="height:60px;width:90px;display:inline-block;">
<a href="#" >
<img style="max-height:60px;height:auto;max-width:90px;width:auto;margin:0 auto;padding:5px;display:inline-block;vertical-align:middle;" src="img1.png" />
</a>
</div>
<div style="height:60px;width:90px;display:inline-block;">
<a href="#" >
<img style="max-height:60px;height:auto;max-width:90px;width:auto;margin:0 auto;padding:5px;display:inline-block;vertical-align:middle;" src="img1.png" />
</a>
</div>
<div style="height:60px;width:90px;display:inline-block;">
<a href="#" >
<img style="max-height:60px;height:auto;max-width:90px;width:auto;margin:0 auto;padding:5px;display:inline-block;vertical-align:middle;" src="img1.png" />
</a>
</div>
</div>
Your code seems to work for me as expected. https://fiddle.jshell.net/ph110293/goetup62/
It didn't work on Firefox ONLY. For Firefox I had to set the 'fieldset' tag style to be 'display:table-column;'. As my main div was inside tags which was in another div with a class of 'container' (Bootstrap), the fieldset kept taking the container width.

How can I solve this styling issues?

I have this code, I heard that hspace will be not in use anymore. How can I add space between them on above and between 10px would be good, I tried with margin-top did not worked and broke my other widgets as well.
Here is an example:
Here the code does not have space between them on vertical
This is the wide view here it looks better, once resized into smaller screens I get the above result
I would like to have 10px beween them and when resized on top too.
I want them all in once code, since this is a widget I want it with built in CSS.
<div align="center">
<a href="https://facebook.com/testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/Facebook.png" align="middle" alt="TestClue on Facebook" height="60" width="60" hspace="10">
</a>
<a href="https://twitter.com/testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/Twitter.png" align="middle" alt="TestClue on Twitter" height="60" width="60" hspace="10">
</a>
<a href="https://www.linkedin.com/company/testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/in.png" align="middle" alt="TestClue on LinkedIN" height="60" width="60" hspace="10">
</a>
<a href="https://plus.google.com/+Testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/G.png" align="middle" alt="TestClue on Google+" height="60" width="60" hspace="10">
</a>
</div>
I would recommend to remove all the inline code that you have on your tags, as some of them got deprecated or are not as useful as the CSS.
I would suggest you to do something like this.
For the HTML:
<div id="social-networks-container">
<div class="social-network">
<a href="https://facebook.com/testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/Facebook.png" />
</a>
</div>
<div class="social-network">
<a href="https://twitter.com/testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/Twitter.png" />
</a>
</div>
<div class="social-network">
<a href="https://www.linkedin.com/company/testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/in.png" />
</a>
</div>
<div class="social-network">
<a href="https://plus.google.com/+Testclue">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/G.png" />
</a>
</div>
</div>
And for the CSS:
#social-networks-container .social-network {
display: inline-block;
margin: 10px;
}
#social-networks-container .social-network a {
display: block;
}
An example of this working: https://jsfiddle.net/vfvhqvzf/1/
UPDATE:
If you just want to use inline code on your html you could also try this:
<div style="display:inline-flex;">
<a href="https://facebook.com/testclue" style="display: block;padding: 10px;">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/Facebook.png" />
</a>
<a href="https://twitter.com/testclue" style="display: block;padding: 10px;">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/Twitter.png" />
</a>
<a href="https://www.linkedin.com/company/testclue" style="display: block;padding: 10px;">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/in.png" />
</a>
<a href="https://plus.google.com/+Testclue" style="display: block;padding: 10px;">
<img src="http://uhl.hosting/wp-content/uploads/2016/02/G.png" />
</a>
</div>
Demo: https://jsfiddle.net/vfvhqvzf/4/
Maybe you can try this:
padding: 10px;
Add:
style="padding-top:10px;"
to each 'a' (anchor) element

Media Queries not working in my HTML code, Not sure what I am doing wrong here

This is my Code for a FAST click on a website.
Website URL: www.vegastoothdr.com/wp_site/
<body>
<div id="wpadminbar" style="background-color: black; padding-top: 0px;border-color: white;">
<span class="row" style="vertical-align: top">
<!-- PHONE ICON -->
<a href="tel:(702) 473-5100">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/phone.png" width="60" height="36" style="padding-left: 20px">
</a>
<!-- CALENDAR ICON -->
<a href="appointment">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/calendar.png" width="60" height="36" style="padding-left: 20px">
</a>
<!-- EMAIL ICON -->
<a href="contact">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/envelope.png" width="67" height="36" style="padding-left: 20px">
</a>
<!-- PIN ICON -->
<a href="https://www.google.com/maps/place/1070+W+Horizon+Ridge+Pkwy+%23121,+Henderson,+NV+89012,+USA/#36.022368,-115.0346407,17z/data=!3m1!4b1!4m2!3m1!1s0x80c8d16f85764fa7:0x702e5efb00bd1ffb">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/pin.png" width="49" height="36" style="padding-left: 20px">
</a>
</span>
</div>
<header>
<!-- Nav CODE -->
</header>
Okay, Now i have the CODE and I placed a CSS code on the last line on the <head>section
#media screen and (max-width: 782px)
{
div#wpadminbar
{
height: 55px;
min-width: 300px;
}
}
Okay... It works on the mobile device now.
But, The links are not working. So i cant click the icons. none of the links are working.
TEST TWO:
I placed it under the Header Section and the links works.. But the media query is not working. Soo weird.
I have placed the code below where the links are working but the media query is not working.
<body>
<header>
<div id="wpadminbar" style="background-color: black; padding-top: 0px;border-color: white;">
<span class="row" style="vertical-align: top">
<!-- PHONE ICON -->
<a href="tel:(702) 473-5100">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/phone.png" width="60" height="36" style="padding-left: 20px">
</a>
<!-- CALENDAR ICON -->
<a href="appointment">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/calendar.png" width="60" height="36" style="padding-left: 20px">
</a>
<!-- EMAIL ICON -->
<a href="contact">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/envelope.png" width="67" height="36" style="padding-left: 20px">
</a>
<!-- PIN ICON -->
<a href="https://www.google.com/maps/place/1070+W+Horizon+Ridge+Pkwy+%23121,+Henderson,+NV+89012,+USA/#36.022368,-115.0346407,17z/data=!3m1!4b1!4m2!3m1!1s0x80c8d16f85764fa7:0x702e5efb00bd1ffb">
<img class="icons" src="http://www.vegastoothdr.com/wp_site/wp-content/uploads/2016/03/pin.png" width="49" height="36" style="padding-left: 20px">
</a>
</span>
</div>
I fixed the issue, There was JS script that was adding a Div for Video. It seems the DIV was on top on my code.
I deleted it and it fixed it :)
Link to the site: http://www.vegastoothdr.com/

change image on hover moves images

I'm having a bit of problem here.
I'm trying to display an image in a circle div (using bootstrap), that when hover, the picture becomes a gif, but if you take your mouse from over the picture, it is only a static image.
It works, almost, as it moves the picture and the frame around, and I can not find why.
Here it is http://jsfiddle.net/eve_mf/zmp7tnho/
<div class="container">
<div class="titleColumns col-md-24">
<h1>Meet Some Of <strong>Our Denison Experts</strong></h1>
<h2>We can have a line about the team</h2>
<div class="personPic col-md-6">
<div class="circleFrame"><img class="static img-circle alignleft wp-image-1008 size-full" src="http://motors06.denison-automotive.co.uk/denison/wp-content/uploads/2015/05/jules_sil5.png" alt="" width="120" height="120" />
<img class="animated img-circle alignleft wp-image-1008 size-full" src="http://motors06.denison-automotive.co.uk/denison/wp-content/themes/denison-automotive/images/jules_sil_gif.gif" alt="" width="120" height="120" /></div>
<span class="peopleName">Jules Perry</span>
<span class="peoplePos">The Thinker</span>
</div>
<div class="personPic col-md-6">
<div class="circleFrame"><img class="static img-circle alignleft wp-image-1012 size-full" src="http://motors06.denison-automotive.co.uk/denison/wp-content/uploads/2015/05/tessa_sil2.png" alt="" width="120" height="120" />
<img class="animated img-circle alignleft wp-image-1012 size-full" src="http://motors06.denison-automotive.co.uk/denison/wp-content/themes/denison-automotive/images/tessa_sil_gif.gif" alt="" width="120" height="120" /></div>
<span class="peopleName">Tessa Denison</span>
<span class="peoplePos">The Creative</span>
</div>
</div>
</div>
I'm just working with html and css
Any suggestions? I've tried to remove all the styles but even then, there is a movement between the pictures and are the same size..
Thank youuuu
In fact, you don't need to set a position at all.
.circleFrame:hover .animated {
display:block;
}
http://jsfiddle.net/zmp7tnho/4/
I recommend you to set border styles to circleFrame too - http://jsfiddle.net/d3z849y7/
It helps you with freezing borders.

Resources