Hide/Show <paragraph> with media query - html

I've coded a site, but I have a question - I have 2 different paragraphs in the same div, but one of them should only show when the screen is 600 or over. Can it be done this way? or should I wrap my in a secondary inside the first
<span class="me-square">
<div class="me-wrapper">
<h3>ABOUT ME</h3>
<p>My name is Katrine, but my friends call me Mira. I’m 20 years old and I live in Denmark.
<p id="me-2ndtext">I want this text to only show when the screen is 600 or over</p>
</div></span>
CSS
#me-2ndtext{
display: none;
}
#media screen and (min-width: 601px) {
div#me-2ndtext {
display: block;
}
}

I would go like this
#media screen and (max-width: 601px) {
#me-2ndtext {
display: none;
}
}

Simple Version
HTML:
<span class="me-square">
<div class="me-wrapper">
<h3>ABOUT ME</h3>
<p>My name is Katrine, but my friends call me Mira. I’m 20 years old and I live in Denmark.
<p id="me-2ndtext">I want this text to only show when the screen is 600 or over</p>
</div>
</span>
CSS:
#media screen and (max-width: 599px) {
p#me-2ndtext {
display: none;
}
}
Or when it's all times the second paragraph you can make it like this:
You don't need the extra id then.
HTML:
<span class="me-square">
<div class="me-wrapper">
<h3>ABOUT ME</h3>
<p>My name is Katrine, but my friends call me Mira. I’m 20 years old and I live in Denmark.
<p>I want this text to only show when the screen is 600 or over</p>
</div>
</span>
CSS:
#media screen and (max-width: 599px) {
p:nth-of-type(2) {
display: none;
}
}

Related

css arrange two elements one after another

How can i display the two links for small screen one after another. Now the two links are left and right. But i want those link one up and another at bottom.
<div className="homeContent">
<div className="content">
<h1>Text</h1>
<div className="pdf">
XX Download
BB Download
</div>
</div>
</div>
#media screen and (max-width:580px){
.homeContent {
h1 {
font-size: 3rem !important;
}
.content {
.pdf {
a {
// one after another
}
}
}
}
}
Adding display:block on a will do what you want, like so (I am using css so that it works here):
#media screen and (max-width: 580px) {
a {
display: block;
}
}
<div className="homeContent">
<div className="content">
<h1>Text</h1>
<div className="pdf">
XX Download
BB Download
</div>
</div>
</div>

Need help stacking blog snippets on mobile to make responsive

The 3 blog posts on this page are no longer stacking (responsive) on mobile. Can someone help me adjust this so the blog post snippets stack on top of each other on mobile? I need it to be responsive on mobile! Also, if you would recommend a way to add a "Read More" link at the bottom of each excerpt that takes users to the blog page.
[![blog posts not stacking][1]][1]
Here is the CSS and you will find the HTML below.
.blog-list {
padding: 0 8px;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
.blog-list li {
padding-bottom: 20px;
}
.blog-list a {
position: relative;
text-decoration: none;
height: 400px;
}
.blog-list img {
display: block;
height: auto !important;
width: 100%;
}
#media only screen and (min-width: 700px) {
.blog-list {
display: grid;
grid-column-gap: 20px;
grid-template-columns: 1fr 1fr 1fr;
}
}
#media only screen and (min-width: 980px) {
.blog-list {
padding-bottom: 25px;
}
.blog-list h3 {
font-size: 2.4rem;
}
.blog-list a {
display: block;
}
.blog-list a img {
transition: ease all .5s;
}
.blog-list a:hover {
opacity: .8;
}
.blog-list + footer {
padding-bottom: 100px;
}
}
<section class="generic">
<div class="inner">
<ul class="blog-list">
<li>
<a href="https://bluestoneconstruction.com/asheville-nc-the-best-place-to-live-if-you-can-live-anywhere/">
<img src="https://bluestoneconst.wpengine.com/wp-content/uploads/2018/11/liveable-cities-where-to-move-if-you-can-live-anywhere-6.jpg" alt="">
<h3>Asheville, NC: The Best Place To Live If You Can Live Anywhere</h3>
</a>
<p>Experienced travelers know the best place to eat in Chicago, the best hotel to stay at in New York, the best place to watch the sunset over the Rocky Mountains, the best beach on the East Coast — you get the picture. But what about moving somewhere new? This requires a different set of criteria. Vacation</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/luxury-mens-brand-chooses-bluestone-home-for-fall-catalog-photo-shoot/">
<img width="920" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg 920w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction.jpg 1024w" sizes="(max-width: 920px) 100vw, 920px">
<h3>Luxury Men’s brand chooses Bluestone custom home for Fall catalog photo shoot</h3>
</a>
<p>After a 4 day photo shoot with luxury fashion brand Peter Millar at our client’s rustic custom home for their fall/ holiday luxury men’s apparel catalog, we got some fun aerial and ground shots of our own thanks to Carl Amoth. Very impressive to see what goes into all of the amazing photographs a brand</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/2020-master-design-award-winner/">
<img width="921" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg 921w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1024x767.jpg 1024w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1536x1151.jpg 1536w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8.jpg 1600w" sizes="(max-width: 921px) 100vw, 921px">
<h3>2020 Master Design Award Winner for Best Outdoor Environment</h3>
</a>
<p>We are so delighted to win another award for this stunning custom home in Fairview, North Carolina. The work we do represents the best of the best in design, materials, and talent. We thank everyone who helped put this project together. It is always a collaborative creative process that leaves us grateful and satisfied standing</p>
</li>
</ul>
</div>
</section>
[1]: https://i.stack.imgur.com/n4jOn.png
Use display: flex on .blog-list instead of display: grid and then add a media query at about 550px and change the flex direction to column:
body {
margin: 0;
}
.blog-list {
display: flex;
margin: 0;
padding: 0;
}
.blog-list li {
padding: 10px;
list-style-type: none;
}
.blog-list a {
position: relative;
text-decoration: none;
}
.blog-list img {
display: block;
height: auto !important;
width: 100%;
}
#media only screen and (max-width: 550px) {
.blog-list {
flex-direction: column;
}
}
#media only screen and (min-width: 980px) {
.blog-list h3 {
font-size: 2.4rem;
}
.blog-list a img {
transition: ease all 0.5s;
}
.blog-list a:hover {
opacity: .8;
}
.blog-list + footer {
padding-bottom: 100px;
}
}
<section class="generic">
<div class="inner">
<ul class="blog-list">
<li>
<a href="https://bluestoneconstruction.com/asheville-nc-the-best-place-to-live-if-you-can-live-anywhere/">
<img src="https://bluestoneconst.wpengine.com/wp-content/uploads/2018/11/liveable-cities-where-to-move-if-you-can-live-anywhere-6.jpg" alt="">
<h3>Asheville, NC: The Best Place To Live If You Can Live Anywhere</h3>
</a>
<p>Experienced travelers know the best place to eat in Chicago, the best hotel to stay at in New York, the best place to watch the sunset over the Rocky Mountains, the best beach on the East Coast — you get the picture. But what about moving somewhere new? This requires a different set of criteria. Vacation</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/luxury-mens-brand-chooses-bluestone-home-for-fall-catalog-photo-shoot/">
<img width="920" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-920x690.jpg 920w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Peter-Millar-photos-with-Bluestone-Construction.jpg 1024w" sizes="(max-width: 920px) 100vw, 920px">
<h3>Luxury Men’s brand chooses Bluestone custom home for Fall catalog photo shoot</h3>
</a>
<p>After a 4 day photo shoot with luxury fashion brand Peter Millar at our client’s rustic custom home for their fall/ holiday luxury men’s apparel catalog, we got some fun aerial and ground shots of our own thanks to Carl Amoth. Very impressive to see what goes into all of the amazing photographs a brand</p>
</li>
<li>
<a href="https://bluestoneconstruction.com/2020-master-design-award-winner/">
<img width="921" height="690" src="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg" class="img-responsive wp-post-image" alt="" loading="lazy" srcset="https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-921x690.jpg 921w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-300x225.jpg 300w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1024x767.jpg 1024w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-768x576.jpg 768w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8-1536x1151.jpg 1536w, https://bluestoneconstruction.com/wp-content/uploads/2020/09/Best-Asheville-nc-luxury-home-builder-Bluestone-Construction-8.jpg 1600w" sizes="(max-width: 921px) 100vw, 921px">
<h3>2020 Master Design Award Winner for Best Outdoor Environment</h3>
</a>
<p>We are so delighted to win another award for this stunning custom home in Fairview, North Carolina. The work we do represents the best of the best in design, materials, and talent. We thank everyone who helped put this project together. It is always a collaborative creative process that leaves us grateful and satisfied standing</p>
</li>
</ul>
</div>
</section>
Here's a link to my Codepen: https://codepen.io/ajarrow/pen/oNxmxGr
EDIT
After looking at your website, it looks like there is a media query with a min-width of 700px (any device with a screen width of greater than 700px, which would be a vary large phone) which is handling the .blog-list element. Under that width, the blog-list element no longer has a grid-column-gap defined and the columns are still set to three columns. So if you add a simple media query like below, it should work as expected:
#media only screen and (max-width: 700px) {
.blog-list {
display: grid;
grid-template-columns: 1fr;
padding: 0 8px;
}
}
Also, some other things I noticed while on your website:
The div with an id of site-frame has a margin-bottom of 515 px to allow the location/contact info at the bottom to be seen when the user scrolls to the bottom of the page. That's cool, except that the margin isn't removed when the location/contact info is moved inside the site-frame at 760px. Yep, you guessed it...add another media query with a max-width of 760px:
#media only screen and (max-width: 760px) {
#site-frame {
margin-bottom: 0 !important;
}
}
And you have to use !important because the original margin is inline, which will override anything else unless you use !important.
And then the images in the 'Featured Projects' directly above the 'News' section were being stretched and shrunk/overlapped by their parent element. After a bunch of head-scratching, I fixed the problem with this CSS:
.project-list a img {
max-height: 100%;
object-fit: contain;
max-width: 100% !important;
}
Those are just some things I noticed, you can do what you want. Also, I still didn't see the CSS I gave you the other day...did you remove it or is it not coming through? It looked like you were using WP...to add custom css, log in to the backend of your site and when you're viewing the front page of your site, hit the 'Customize' button (paintbrush icon on mobile) in the header bar at the top. Scroll to the bottom, select 'Additional CSS', and paste the code box on the left. Let me know the results!
EDIT
A very simple way to add 'Read More' buttons would be to borrow the styling from the class special-button (which is being used on the 'Meet With Us' button directly below the posts) with an a element:
Read More
You would have to add this to the bottom of each post and change the href attribute manually. A more dynamic way to do it would be to add this bit of javascript AFTER the blog posts:
<script>
document.querySelectorAll('.blog-list li a').forEach(function(item) {
var newA = document.createElement('a');
newA.href = item.href;
newA.classList = 'special-button';
newA.textContent = 'Read More';
item.parentElement.insertAdjacentElement('beforeend', newA);
});
</script>

Hiding an image on mobile only using CSS

I would like to have my site remove an image only on mobile which I was able to accomplish using
#media (max-width: 480px) {
.slide-6996 {
display:block !important;
}
.slide-6996 {
display:none !important;
}
}
However, I also would still like to display the text that was on the slide that I am now not showing. I have tried this in CSS, but it obviously didn't work.
#media (max-width: 480px) {
.slide-6996 {
display:block !important;
}
.slide-6996 {
display:none !important;
#slide-content {
display: block !important;
}
}
}
My HTML for this specific instance is
<div id="slide-6996" class="slide slide-6996 cycle-slide-active slide-left light" style="background-image:url(http://18.205.33.160/wp-content/uploads/2019/02/ITData-Home-Page2018-01-edited.jpg);">
<div class="slide-body">
<div class="container">
<div class="slide-caption">
<div class="slide-content">
<h1><strong>COMPREHENSIVE IT SERVICES YOU CAN TRUST</strong></h1>
</div>
<h2 class="slide-title"> Let us help you develop an IT Optimization Strategy and Define your technological priorities </h2>
<a class="slide-link button button-medium" href="http://18.205.33.160/index.php/itone-method/?customize_changeset_uuid=56ed31cf-ab75-46c7-bf6a-d1eb013fed32&customize_messenger_channel=preview-0&customize_autosaved=on" target="_self"> Learn how we can help you succeed </a>
</div>
<div class="slide-image"></div>
</div>
</div>
</div>
It should also be worth noting that I am on WordPress and am open-minded to any suggested plugins that may fix my issue.
You can't override inline CSS using external CSS, but what you can do is edit your HTML a bit. By adding a new class in that div and in the external CSS you can make rules for what and when to apply.
So, in first line add a new class "background-cls"—your first line needs to be like this:
<div id="slide-6996" class="slide slide-6996 cycle-slide-active slide-left light background-cls">
Then in your external CSS add something like this:
#media (max-width: 480px) {
.background-cls {
background-image: none !important;
}
}
.background-cls {
background-image: url(http://18.205.33.160/wp-content/uploads/2019/02/ITData-Home-Page2018-01-edited.jpg);
}
Here's a fiddle: https://jsfiddle.net/2xb34dev/
With your markup this should work:
#media only screen and (max-width: 480px) {
.slide-6996 .slide-image {
display: none !important;
}
}
Hope that solves it.
You can use #media and then hide that class.
#media (max-width: 576px){
.yourclass{
display:none;
}
}
You can choose 767px or 992px for larger size or you can give your #media with between sizee like following example:
#media screen and (max-width: 576px) and (min-width: 767px) {
.yourclass {
display: none;
}
}

CSS - display:none action not working

I have a staff section on a Wordpress site I'm building with hover effects across each staff member image showing their name, job title and bio.
The staff bio's are quite long and the client is reluctant to change them, however, when looking at the effects on tablet/mobile screen sizes the bios don't fit the smaller image.
I've tried changing the font-size but if I reduce it any further the text will be unreadable.
Rather than change the bio size what I want to do in the media queries is block out the bio's and just leave the name & title using display:none; for the bio <p> tags but I can't get it to work.
Is this the best way to do it?
This is the code for one of the images -
html/php
<div class="staff">
<div class="masonry">
<div class="brick">
<?php if( get_field('whoweare_image1') ): ?>
<img src="<?php the_field('whoweare_image1'); ?>" />
<?php endif; ?>
<div class="details">
<span id="info">
<h3><?php the_field('whoweare_name1'); ?></h3>
<p class="bio"><?php the_field('whoweare_text1'); ?></p>
</span>
</div>
</div>
<!-- identical code for other staff member images -->
</div>
</div>
And this is what I've tried for the media queries (for ipad/tablet portrait) -
style.css
#media only screen and (min-width: 750px) and (max-width: 960px) {
.staff .brick .details #info .bio p {
display: none;
}
}
I added the bio class to the <p> tags after I tried this CSS rule below and it blocked out the whole text including name/title -
#media only screen and (min-width: 750px) and (max-width: 960px) {
.staff .brick .details #info p {
display: none;
}
}
Any assistance would be appreciated.
The selector has to be
.staff .brick .details #info p.bio { ... }
("bio" is the class applied to the p tag)
your target wrong
#media only screen and (min-width: 750px) and (max-width: 960px) {
.staff .brick .details #info p.bio {
display: none;
}
}
https://jsfiddle.net/pcto2Lkj/1/
You can do like below css styles.
#media only screen and (min-width: 750px) and (max-width: 960px) {
.staff .details #info .bio {
display: none;
}
}
Having inspected the elements a little closer I discovered that Wordpress have done that strange thing and added a class to the <p> tag - <p class="p2">so I targeted this attribute and it worked -
.staff .brick .details #info p.p2 {
display: none ;
}
I don't fully understand why these attributes are created, however, this has cleared up why the <p> tag wouldn't work.

How can I make text drop down to a second line using media queries?

When my site is at a specific size I want the logo to break in half so that Photography & Design are on a second line. How would I accomplish this?
#media only screen and (max-width: 424px) {
}
<nav>
<h1 class="logo">Brian Funderburke Photography & Design</h1>
</nav>
The simplest way would be to add a span that wraps around what you want to be on its own line, then target it, and assign it display: block;
I highly recommend you make this more robust with proper class name selection and so forth.
HTML:
<nav>
<h1 class="logo">Brian Funderburke <span>Photography & Design</span></h1>
</nav>
CSS:
#media only screen and (max-width: 424px) {
.logo span {
display: block;
}
}
https://jsfiddle.net/6vcbdqqk/
if it is only about this very h1 and this very text, then set a width to force text to wrap.
#media only screen and (max-width: 424px) {
h1 {
width: 10em;
}
}
.demo {
width: 10em;
border: solid;
/* remove this, demo purpose */
}
<nav>
<h1 class="logo">Brian Funderburke Photography & Design</h1>
</nav>
<p>below for demo</p>
<h2 class="demo">Brian Funderburke Photography & Design</h2>
<h3 class="demo">Brian Funderburke Photography & Design</h3>
<p class="demo">Brian Funderburke Photography & Design</p>