简体   繁体   English

所选文字在640像素或更小的视口中逐渐消失

[英]Selected text fades away in a 640px or less viewport

I have a page that if you click one of the boxes shown in my snippet, a checkmark shows up and the content inside of shows as if it is active after you move the mouse away from it. 我有一个页面,如果您单击我的代码段中显示的框之一,则会出现一个选中标记,并且将鼠标移开后,其中的内容就会显示为活动状态。 However, when viewed with a viewport of 640px or less, the text inside of the boxes fades away after you select it and select something else. 但是,当使用640像素或更小的视口查看时,选择并选择其他内容后,框内的文本会淡出。 It is not doing this in a normal desktop view, so why is it doing it withing that specific media query? 它不是在普通的桌面视图中执行此操作,那么为什么要针对特定​​的媒体查询执行此操作? I did not make any changes to my .box-focused css in the media query at all, nor did I even include it because I wanted everything the same. 我根本没有对媒体查询中以.box-focused css进行任何更改,甚至也没有包含它,因为我希望所有内容都一样。

Does anyone see what it is that is causing this to happen? 有人看到导致这种情况发生的原因是什么?

 $('.project-option-boxes').click(function() { $(this).hide().toggleClass('box_focused').fadeIn('slow'); }); 
 #project-scope-container { margin-top: 70px; margin-left: 9%; width: 75%; height: 300px; } .project-option-boxes { display: inline-block; border: 1px solid #45ba95; padding: 20px 0px; margin: 12px 20px 12px 0px; width: 30%; text-align: center; font-size: 1.2em; color: #45ba95; cursor: pointer; transition: ease-in-out .5s; } .project-option-boxes:hover { background-color: #45ba95; color: #FFF; transition: ease-in-out .5s; } .box_focused { background-color: #45ba95; color: #FFF; background-image : url("http://optimumwebdesigns.com/icons/white_checkmark.png"); background-position: left center; background-repeat: no-repeat; background-size: 20px 20px; background-position: 5% 50%; } @media screen and (max-width:640px) { .project-option-boxes { display: block; border: 1px solid #45ba95; padding: 20px 0px; margin: 15px 0px 15px 0px; width: 85%; text-align: center; font-size: 1.2em; color: #45ba95; cursor: pointer; } .project-option-boxes:hover { background-color: #45ba95; color: #FFF; } } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="project-scope-container"> <div id="project-scope-title">PROJECT SCOPE</div> <div class="project-option-boxes">BRANDING & IDENTITY</div> <div class="project-option-boxes">WEB DESIGN</div> <div class="project-option-boxes">RESPONSIVE/MOBILE</div> <div class="project-option-boxes">MARKETING ASSETS</div> <div class="project-option-boxes">HTML5 ANIMATION</div> <div class="project-option-boxes">SEO OPTIMIZATION</div> <div class="project-option-boxes">MONTHLY SUPPORT</div> <div class="project-option-boxes">WEB DEVELOPMENT</div> <div class="project-option-boxes">ECOMMERCE</div> </div> 

You aren't setting the colours correctly for the focused styles in the media query. 您没有为媒体查询中的聚焦样式正确设置颜色。 See my addition of the box_focused class to the media query below. 请参阅下面将我添加的box_focused类添加到媒体查询中。

 $('.project-option-boxes').click(function() { $(this).hide().toggleClass('box_focused').fadeIn('slow'); }); 
 #project-scope-container { margin-top: 70px; margin-left: 9%; width: 75%; height: 300px; } .project-option-boxes { display: inline-block; border: 1px solid #45ba95; padding: 20px 0px; margin: 12px 20px 12px 0px; width: 30%; text-align: center; font-size: 1.2em; color: #45ba95; cursor: pointer; transition: ease-in-out .5s; } .project-option-boxes:hover { background-color: #45ba95; color: #FFF; transition: ease-in-out .5s; } .box_focused { background-color: #45ba95; color: #FFF; background-image : url("http://optimumwebdesigns.com/icons/white_checkmark.png"); background-position: left center; background-repeat: no-repeat; background-size: 20px 20px; background-position: 5% 50%; } @media screen and (max-width:640px) { .project-option-boxes { display: block; border: 1px solid #45ba95; padding: 20px 0px; margin: 15px 0px 15px 0px; width: 85%; text-align: center; font-size: 1.2em; color: #45ba95; cursor: pointer; } .project-option-boxes:hover, .box_focused { background-color: #45ba95; color: #FFF; } } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="project-scope-container"> <div id="project-scope-title">PROJECT SCOPE</div> <div class="project-option-boxes">BRANDING & IDENTITY</div> <div class="project-option-boxes">WEB DESIGN</div> <div class="project-option-boxes">RESPONSIVE/MOBILE</div> <div class="project-option-boxes">MARKETING ASSETS</div> <div class="project-option-boxes">HTML5 ANIMATION</div> <div class="project-option-boxes">SEO OPTIMIZATION</div> <div class="project-option-boxes">MONTHLY SUPPORT</div> <div class="project-option-boxes">WEB DEVELOPMENT</div> <div class="project-option-boxes">ECOMMERCE</div> </div> 

You have to have the same css settings copied into the media query for the same to apply. 您必须将相同的CSS设置复制到媒体查询中才能应用。 its because the scope limits what code is read 这是因为范围限制了读取什么代码

 $('.project-option-boxes').click(function() { $(this).hide().toggleClass('box_focused').fadeIn('slow'); }); 
 #project-scope-container { margin-top: 70px; margin-left: 9%; width: 75%; height: 300px; } .project-option-boxes { display: inline-block; border: 1px solid #45ba95; padding: 20px 0px; margin: 12px 20px 12px 0px; width: 30%; text-align: center; font-size: 1.2em; color: #45ba95; cursor: pointer; transition: ease-in-out .5s; } .project-option-boxes:hover { background-color: #45ba95; color: #FFF; transition: ease-in-out .5s; } .box_focused { background-color: #45ba95; color: #FFF; background-image : url("http://optimumwebdesigns.com/icons/white_checkmark.png"); background-position: left center; background-repeat: no-repeat; background-size: 20px 20px; background-position: 5% 50%; } @media screen and (max-width:640px) { .project-option-boxes { display: block; border: 1px solid #45ba95; padding: 20px 0px; margin: 15px 0px 15px 0px; width: 85%; text-align: center; font-size: 1.2em; color: #45ba95; cursor: pointer; } .project-option-boxes:hover { background-color: #45ba95; color: #FFF; transition: ease-in-out .5s; } .box_focused { background-color: #45ba95; color: #FFF; background-image : url("http://optimumwebdesigns.com/icons/white_checkmark.png"); background-position: left center; background-repeat: no-repeat; background-size: 20px 20px; background-position: 5% 50%; } } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="project-scope-container"> <div id="project-scope-title">PROJECT SCOPE</div> <div class="project-option-boxes">BRANDING & IDENTITY</div> <div class="project-option-boxes">WEB DESIGN</div> <div class="project-option-boxes">RESPONSIVE/MOBILE</div> <div class="project-option-boxes">MARKETING ASSETS</div> <div class="project-option-boxes">HTML5 ANIMATION</div> <div class="project-option-boxes">SEO OPTIMIZATION</div> <div class="project-option-boxes">MONTHLY SUPPORT</div> <div class="project-option-boxes">WEB DEVELOPMENT</div> <div class="project-option-boxes">ECOMMERCE</div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当浏览器小于640px时如何将列表项转换为滑块? - how to convert list item to slider when browser is less than 640px? 仅为屏幕大于640像素的设备加载图像 - Load images only for devices with > 640px screen 对于网络应用,iPhone 4+默认为320px分辨率,我想使用完整的640px - iPhone 4+ defaults to 320px resolution for web apps, I want to use the full 640px 如何使目标宽度和高度大于640像素的高质量PhoneGap摄像机图像? - How can I make PhoneGap Camera images with target width and height bigger than 640px of high quality? 元视口仅适用于移动设备(屏幕宽度小于640) - meta viewport only for mobile (screen width less than 640) 当视口小于 481px 时禁用 slick slider - Disable slick slider when viewport is less than 481px 为什么日期选择器会消失? - why does datepicker fades away? bootstrap工具提示会显示文本并正确消失,但是它不在图标上方的工具提示中 - bootstrap tooltip displays text and fades away properly, but is not located in a tooltip above the icon 悬停背景上的文字变暗 - Text fades in on hover background darkens 有没有一种方法可以创建加载屏幕,但要在消失之前设置时间? - Is there a way to create a loading screen but cap the time before it fades away?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM