My spans with hover work on a tablet (my iPad) and desktop computer. However, on my phone the CSS styling disappears, while I understand that hover effects don't really "work" on phones/touch screens but part of the CSS is hiding the span when not hovered over.
HTML:
<section id="proj1">
<a href="EJ.html">
<img id="c" src="img/rjcover.jpeg">
</a>
<span id="one">
Envisioning Justice
<br>
<br>
May 2020
</span>
</section>
CSS:
span {
display: none;
position: absolute;
font-size: 10px;
padding: 5px;
text-transform: uppercase;
z-index: 1;
font-family: 'Darker Grotesque', sans-serif;
font-size: 25px;
background-color: #FAD714;
color: white;
width: 75%;
margin-top: -190px;
}
#proj1:hover #one {
display: block;
}
#proj2:hover #two {
display: block;
}
#proj3:hover #three {
display: block;
}
#proj4:hover #four {
display: block;
}
http://iam.colum.edu/students/riley.jakusik/designbyriley/
that is the link to it live.
You should always take into consideration what will create the best user-experience. If you are setting display:none on your span element and then displaying that element on hover you are creating a situation for users who are on a device that does not support the hover state that will not be the best experience for them. One possible solution would be to use a hover media query. This way you can specify styling that will apply to users that are on a device that supports that feature, and if not you can specify a fallback for users that are on a device that does not:
#media (hover: hover) {
#one {
display: none;
}
#proj1:hover #one {
display: block;
}
}
The CSS #supports rule will also be a useful tool to familiarize yourself with.
EDIT: And thank you to #SandeshSapkota for pointing out that hover state is still supported in many mobile devices, but I think that it is useful to familiarize yourself with the aforementioned hover media query as it is a useful tool in many situations. A better approach to your issue may be to instead implement a media query that tests for viewport width, and if it is smaller than say 641px, which is the value that Foundation uses to detect mobile devices then just show the span element by default:
#media (max-width: 641px) {
#one {
display: block;
}
This query means that if the device in question has a viewport width at a maximum of 641px then apply the styles.
Related
I'm trying to add iframe to Wordpress pages. I want to display iframe A for desktop users and iframe B for mobile users, because some elements just don't work with mobile devices and at the same time I don't want to lose functionality for the desktop version. I'm pretty new to coding, so detailed explanation how to solve this would be very welcome.
One way of doing this is using CSS media queries. #media(max-width: 540px) contains styles that will only apply on screens of width at most 540px (and you can change the number to whatever suits your needs).
And, I imagine you could do this too to the actual page pointed at by the iframe, so that you don't need two iframes in the first place. I.e. apply media queries directly to the page that has buttons to show/hide on mobile.
/* mobile (you can change 540px to whatever breakpoint you like) */
#media(max-width: 540px) {
.desktop {
display: none;
}
.mobile {
display: block;
border: 1px solid red;
}
}
/* desktop */
#media(min-width: 541px) {
.desktop {
display: block;
border: 1px solid cyan;
}
.mobile {
display: none;
}
}
<iframe class="desktop"></iframe>
<iframe class="mobile"></iframe>
I Know that internet explorer doesn't play nice with SVGs. I notice that when changing display: block to display: flex does decreases the size of the gap. however it doesn't remove it.
I am declaring height and width in the styles but the issue seems to persist in IE 11
// Declarations
.o-navigation {
align-items: center;
display: flex;
#include font-smooth;
padding: (.5 * $spacing-base) $spacing-base;
.logo-access {
.icon-logo-full {
width: 135px;
height: 23px;
display: block;
#media screen and (min-width: $screen-desktop) {
.home & {
width: 270px;
height: 45px;
}
}
}
}
}
https://github.com/CityOfNewYork/ACCESS-NYC-PATTERNS/blob/master/src/objects/navigation/_navigation.scss
Where might the issue come from?
After using F12 developer tools to check the CSS style, I think the problem is caused by the different rendering way in IE11 that leads to the "o-navigation color-dark-background" having different heights in IE11 and other browsers. You can give the "o-navigation color-dark-background" a specific height value familiar with the value in other browsers. Here I try to set the height value to 52px and then the gap disappears. Like this:
IE doesn't play well with SVGs. The other answer to this post regarding adding the height style to the page does seem to work, and many other post regarding this issue direct to that solution. What did it for me was adding overflow: hidden to the links in the nav.
.nav-inline {
#include typography-nav();
list-style: none;
text-align: $text-direction-end;
flex: 1 1 auto;
margin: 0;
padding: 0;
a {
display: inline-block;
margin-#{$text-direction-start}: 1em;
overflow: hidden;
}
I'm currently trying to mimic this layout using HTML/CSS. Attached is what it should look like on Desktop and Mobile. For mobile, I'm not 100% sure the best approach for this. Notice how the image comes before "Bowers & Wilkins".
The layout is 100% browser width btw. My initial thought was to use flex boxes for this...but I'm not 100% sure if it's the right approach. I'm currently pretty new to using flex boxes.
Simplest way would probably be to float the image to the right at desktop res (initially shown in a single column in the demo when you run the below snippet - effectively mobile res. If you switch to full page mode, you should see the element order change so the image floats to the right):
body {
font-family: Arial, sans-serif;
background-color: #aaa;
padding: 1em;
font-size: 14px;
}
h1,
h2,
p {
margin: 0;
color: #fff;
}
/* float image to the right, half the width of the viewport */
img {
float: right;
margin-left: 1em;
width: 50vw;
}
h1 {
font-size: 1.25em;
font-weight: normal;
}
h2 {
text-transform: uppercase;
font-size: 1em;
}
#media only screen and (max-width: 767px) {
/* at mobile res, remove the float so the image appears back between the headings */
img {
float: none;
margin-left: 0;
margin-bottom: .75em;
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css" />
<h1>Exclusive offers from our partners</h1>
<img src="http://lorempixel.com/output/technics-q-c-200-200-4.jpg" />
<h2>Bowers & Wilkins</h2>
<p>It's one thing to dress well for your party. It's another thing to host it well ...</p>
I would definitely recommend bootstrap as a good solution for this. They have pre-built CSS classes that can pull and push and rearrange objects like this automatically.
Here the classes would be class="col-md-6 col-md-push-6" and class= "col-md-6 col-md-pull-6"
Hi I'm still new to web development. So I have a register page that floats as a div above the main page but I was wondering how do I ensure that the div gets centered in a responsive manner?
The pages are separated and included at the header.
<?php
include ('includes/login.php');
include ('includes/register.php');
?>
my register's css
#regScreen {
padding: 5 5 40px 5px;
margin: 0 auto;
position: fixed;
top: 5%;
left: 33%;
z-index: 10;
display: none;
background: #ebebeb;
}
#regScreen:target, #regScreen:target+#cover {
display: block;
opacity: 2;
}
#reghead {
background-color: #e2e1e1;
text-align: center;
display: block;
padding: 0px 0px 10px 0px;
}
I tried to use media query on my #regscreen:
#media (max-width: 300px) {
#regScreen {width: 100%;
left:0%;
}
}
But using media queries doesn't seems to recognize the page as responsive as it is already small. From my understanding, please correct me if I'm wrong.
It's difficult to provide an exact answer without more infomation (it would be great if you added more of the HTML markup), however...
If the issue is that the floating div does not resize to fit various screen sizes (and since you're new to web development...welcome aboard!), there are a couple of suggestions I can make:
1) You may be overcomplicating it by trying to apply the #media (max-width:300px) media query. By simply adding the following styles, the registration form should resize accurately:
#regScreen {
/* The rest of your styles go here */
width:90%;
max-width:600px; /* em or rem value would be better than px... e.g. 37.5 em */
}
This would ensure that the width of the form is always either 90% of the screen width OR 600px, whichever is smaller.
2) If you think there may be an issue with the media query not trigerring, an easy way to test it is to make something really obvious happen at that breakpoint...for example:
#media (max-width: 300px) {
/* Test Style */
/* Turn background red when below 300px */
body{
background-color:red !important;
}
/* Your original styles */
#regScreen {
width: 100%;
left:0%;
}
}
By doing this, it should allow you to start troubleshooting whether it's your media query syntax or something else that is the issue; maybe the media query styles are being correctly applied (so your media query syntax is ok) but the new styles are being overwritten later in the CSS (or due to the specificity of certain rules).
If you add more info to your question, let me know and I'll take another look but until then, this should hopefully help get you on the right track.
I'm not sure about what is the element using those selectors, but I tried to make a sample html & css reference for solving your issue. Here is the link jsfiddle.net/3Le34w8p/
i already see one error just by looking
#media and (max-width: 300px) {
#regScreen {
width: 100%;
left:0%;
}
}
you for got 'and' before '(max-width: 300px)'
I am having some trouble with CSS, when i try the site on a mobile device the line height remains at 65px , this can be fixed by putting a !important in front but this is not the kind of fix i want, should i be using a class or something?
Thank you very much
/*Change the glyph size when necessary*/
#media only screen and (max-width:990px)
{
#IEGlyphPlacement
{
line-height: 80px;
}
}
#Glyph
{
line-height: 65px;
}
You're targeting a different element inside of the media query. The media query is targeting the element with an ID of IEGlyphPlacement, rather than Glyph (which you define in the non-media query code).
Update as follows:
/*Change the glyph size when necessary*/
#media only screen and (max-width:990px)
{
#Glyph
{
line-height: 80px;
}
}
#Glyph
{
line-height: 65px;
}