CSS - display:none action not working - html

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.

Related

Media min-width display is overwritten by class style

I'm trying to show a <span> when #media (min-width: 600px) and in other cases to hide that <span>
So i've created a class called elimina-text with display set to none then in media query i'm setting that class to display inline but the media query is overwritten and the text is not shown...
So my anchor where i have to hide the text looks like this
#media screen and (min-width: 600px) {
.elimina-text {
display: inline;
}
}
.elimina-text {
display: none;
}
<a _ngcontent-qmm-c108="" href="" apphref="" class="text-muted button-remove" ng-reflect-href=""><i _ngcontent-qmm-c108="" class="material-icons">delete</i><span _ngcontent-qmm-c108="" class="elimina-text">Elimina</span></a>
Change the order of the CSS.
.elimina-text {
display: none;
}
#media screen and (min-width: 600px) {
.elimina-text {
display: inline;
}
}
<a _ngcontent-qmm-c108="" href="" apphref="" class="text-muted button-remove" ng-reflect-href=""><i _ngcontent-qmm-c108="" class="material-icons">delete</i><span _ngcontent-qmm-c108="" class="elimina-text">Elimina</span></a>

Hide/Show <paragraph> with media query

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;
}
}

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;
}
}

#media query not working (not changing color of <h1>)

I am trying to change color of tag on screen resizing. My html page has
following lines
<meta name="viweport" content="width=device-width, inital-scale=1.0">
.
.
<div class="container">
<div id="bg">
<img src="/affeo/img/lll1.jpg" class="img-responsive"/>
</div>
</div>
<div class="container">
<div class="jumbotron text-left" id="jumboText">
<h1>Hello World 0</h1>
</div>
</div>
CSS file has following style:
#media all and (max-width: 1000px) {
#bg {
display:none;
}
#jumboText h1 {
color: black;
}
}
.
.
#jumboText {
position: absolute;
top: 20%;
left: 15%;
background-color:transparent;
}
#jumboText h1 {
position: absolute;
padding-left: 10px;
color: #FFFFFF;
opacity: 0;
white-space: nowrap;
}
Now when I am resizing the screen, image in id:bg is disappearing as expected, but color of jumboText is not changing to black.
Move your media query to the bottom of your code.
The way you have it now - the code inside your media query will be overridden by your regular code
Alternatively, you could increase the specificity of the classes within the media query by say adding the body tag in the selectors
#media all and (max-width: 1000px) {
body #bg {
display:none;
}
body #jumboText h1 {
color: black;
}
}
You need to declare the media queries styles after the non-media query styles - towards the bottom. Otherwise the media queries are overwritten.
There is also a opacity:0; declared on the h1 which needs to change in the media query.
http://jsfiddle.net/omupxnhm/6/

Does display block and display none not supported in IE8?

I have used two images under a table row with id "bannerweb" for web/common and id "bannermobile" for mobile and tab compatibility.
<tr>
<td valign="top">
<img src="http://campaign.vmware.com/imgs/apac/templates/20596_APAC_ASEAN_Bootcamp/images/Architect_Bootcamp_masthead1.jpg" id="bannerweb" width="700" height="189">
<img src="http://images.connect.vmware.com/eloquaimages/clients/VMWare/{b28e5230-1543-4326-8ee8-a780172f2a75}_Architect_Bootcamp_masthead1_mobile.jpg" id="bannermobile" />
</td>
</tr>
and the style applied as such,
<style type="text/css">
For mobile compatibility,
<!--Mobile-->
#media only screen and (min-width: 0px) and (max-width: 361px) {
#bannerweb{
display:none;
visibility:hidden;
}
#bannermobile{
display:block;
width:235px;
}
}
For tablet view,
<!--Tablet-->
#media screen and (min-width: 362px) and (max-width: 561px) {
#bannerweb{
display:block;
width:500px;
height:150px;
}
#bannermobile{
display:none;
visibility:hidden;
}
}
And this style is applied commonly for all web pages.
<!--Common-->
#media screen and (min-width: 562px) and (max-width: 2000px) {
#bannerweb{
display:block;
}
#bannermobile{
display:none;
visibility:hidden;
}
}
</style>.
But in the above code is not reflected in IE 8 alone. display block and none doesny work in IE 8. Any soultions?
Are you using RespondJs?
IE8 doesn't support by default the media queries, that might be your problem