the `display: none;` did not work - css

Why my qrcode-big do not hidden, the bellow is my component code:
<script>
export default{
name: 'iheader',
data(){
return {
qrcodeIsHidden:true
}
},
components: {},
methods: {
overShow(){
this.qrcodeIsShow=true
},
outHide(){
this.qrcodeIsShow=false
}
}
}
</script>
<style scoped>
...
.qrcode-big {
width: 110px;
height: 140px;
background-color: #fff;
text-align: center;
position: absolute;
right: 10px;
top: 50px;
z-index: 100;
}
.i-hide {
display: none;
}
.qrcode-big img, span {
margin: 0 auto;
}
.qrcode-big img {
display: block;
width: 50px;
height: 50px;
margin-top: 20px;
margin-bottom: 14px;
}
.box-shadow{
-webkit-box-shadow:0 0 10px rgba(204, 204, 204, .5);
-moz-box-shadow:0 0 10px rgba(204, 204, 204, .5);
box-shadow:0 0 10px rgba(204, 204, 204, .5);
}
.qrcode-big span {
font-size: 12px;
color: #000;
}
.qrcode img {
line-height: 68px;
width: 14px;
height: 14px;
margin: 4px auto -4px auto;
background-color: #c3c3c3;
}
.flex-box {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
</style>
there is the html code:
<template>
......
<div class="right-buttons ">
<div class="qrcode" #mouseover="overShow" #mouseout="outHide">
<img src="../../assets/img/home/little-qrcode.png">
</div>
<div class="login-logout">
<a>登录/注册</a>
</div>
</div>
<div :class="{ 'qrcode-big': true, 'box-shadow': true, 'i-hide':qrcodeIsHidden }">
<img src="../../assets/img/home/little-qrcode.png">
<span>请扫码关注,接收重要通知</span>
</div>
</div>
</div>
</template>
there are some indifferent code upper you can ignore them, the key code are qrcode-big, its display:none; do not work, you can check in the bellow.
from the snapshot you can see the i-header's style:
the display: none; is strikethrough, why it do not work there?
the snapshot is there, why it do not hidden?
the display: none; did not work.

Sounds like it might be a case of css specificity. Some other style rule is overriding the i-hide class.
For a css class that is required to perform an exact task, using !important might be ok. However, it is better to avoid as it can lead to problems later on.
But you can at least quickly test with it:
.i-hide,
div.i-hide,
.container .i-hide{
display: none!important;
}
And if that works, then if you prefer not to use the !important, then remove it and see if the new specificity of the call was sufficient. Or if it still don't work, then try additional specifications of the class hereditary.
NB: you can try these edits rght in the Developer console... so you can quickly see which is the best combination. Just edit the style in the styles window.

Related

How to make the padding in scrollbar? CSS

I've tried everything, searched the whole stack overflow and google.
Can someone help me to make this particular type of scrollbar?
When I use the border-right/top/bottom to make the spaces around it, it breaks the border-radius and gets ugly. As a reference, it's the same scrollbar used in Googledocs, a slim, rounded and doesn't touch the margins of the page: https://docs.new/
Here's the image: rounded, slim and not touching
So far I got:
::-webkit-scrollbar {
background: #262338;
width: 6px;
}
::-webkit-scrollbar-thumb {
padding: 0 4px;
background: #6E7191;
border-radius: 6px;
height: 48px;
}
::-webkit-scrollbar {
width: 10px;
height: 10px;
border-radius: 34px;
}
/* Track */
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 8px;
transition: all 0.4s;
-moz-transition: all 0.4s;
-webkit-transition: all 0.4s;
}
/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
background: #555;
border-radius: 16px;
}
This would get you the main design of the scrollbar you are looking. This is what I used on my website. Hope this is the design you want!
Scrollbar Padding
I think you'll have to use a container to accomplish the not touching part of your requirements.
Chrome vs Firefox
Be aware that the support to adjust the scrollbar is very limited in firefox compared to chrome browsers. The result of it will not show up in this snippet, nor on websites like jsfiddle. Rounded corners are impossible to achieve in firefox without using your own implementation or a third party library like thisone for example.
Example
body {
background-color: #14142B;
}
/* FIREFOX */
html {
scrollbar-width: thin;
scrollbar-color: #6E7191 #262338;
}
/* CHROME */
::-webkit-scrollbar {
width: 12px;
border-radius: 34px;
}
::-webkit-scrollbar-track {
background: #262338;
border-radius: 8px;
}
::-webkit-scrollbar-thumb {
background: #6E7191;
border-radius: 8px;
transition: all 0.4s;
-moz-transition: all 0.4s;
-webkit-transition: all 0.4s;
}
::-webkit-scrollbar-thumb:hover {
background: #7E81A1;
}
.container {
margin: 1.5rem .5rem;
overflow-y: scroll;
max-height: calc(100vh - 3rem);
}
.content {
height: 25rem;
}
hr {
border: 0;
border-top: 2px solid #201F36;
}
.filler {
height: 3rem;
}
<div class="container">
<div class="content">
<div class="filler"></div>
<hr>
<div class="filler"></div>
<hr>
<div class="filler"></div>
<hr>
<div class="filler"></div>
</div>
</div>

Override bootstrap css only in one react component

so I'm using a gorgeous search bar component that I found on codepen in my react (CRA) project.
I have imported css in the default src/index.js
Then I have my search component which is composed of Search.js and Search.module.css.
Clearly Bootstrap styling and the Search component styling doesn't work together, when I comment the bootstrap file import in src/index.js, the Search component will be working fine.
So how can I override bootstrap only on my Search Component?
Here is the css of the Search.module.css
#import url("https://fonts.googleapis.com/css?family=Roboto:400,400i,700");
* {
font-family: Roboto, sans-serif;
padding: 0;
margin: 0;
}
.flexbox {
background: linear-gradient(155deg, #cccccc, #e8ecee, #d4d4d4);
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.search {
margin: 20px;
}
.search>h3 {
font-weight: normal;
}
.search>h1,
.search>h3 {
color: white;
margin-bottom: 15px;
text-shadow: 0 1px #eaeff1;
}
.search>div {
display: inline-block;
position: relative;
}
.search>div:after {
content: "";
background: white;
width: 4px;
height: 20px;
position: absolute;
top: 40px;
right: 2px;
transform: rotate(135deg);
box-shadow: 1px 0 #eaeff1;
}
.search>div>input {
color: white;
font-size: 16px;
background: transparent;
width: 25px;
height: 25px;
padding: 10px;
border: solid 3px white;
outline: none;
border-radius: 35px;
box-shadow: 0 1px #eaeff1;
transition: width 0.5s;
}
.search>div>input::placeholder {
color: #5a5a5a;
opacity: 1;
}
.search>div>input::-ms-placeholder {
color: #efefef;
}
.search>div>input::-ms-input-placeholder {
color: #5a5a5a;
}
.search>div>input:focus,
.search>div>input:valid {
width: 250px;
}
As you haven't shared the code snippets. I am assuming the bootstrap search will be using: text and button tag. Now, the CSS of this would be coming from bootstrap.
You can do the following:
1) Make a search component level class eg "search-module"
2) Now, create css or scss file import in the search component and within that css
override the bootstrap css by :
.search-module input[type=search] {...}
OR
3) you can do this overriding on your main style.css file too.
You need do to step 2 for all the other conflicting classes, tags, and IDs in the bootstrap with the search component.
PS: This will bloat your CSS. Best would be if you can just pick that part of Bootstrap which is required and rest you write your own style.
Thank you.

CSS fill parent width

I'm struggling to set the div width to the remaining width of the container div. In the example below I want the red div (an input) to take as much space as possible. If you enter anything in the input the green div appears, which should always be right aligned.
I don't want to use either flex nor display: table-* or workarounds like setting overflow: hidden for to make space for floats.
EDIT: I'm looking for any solution that works for IE10+ (including display: table-*, etc.)
Example: https://codesandbox.io/s/23xo3wjjrp (Change the template and style tag inside /components/SearchBox.vue for changes)
The example uses vue, but for completeness I post the code here too:
HTML
<div class="ms-Fabric ms-SearchBox" :class="searchBoxStyle">
<div class="ms-SearchBox-iconContainer">
<i class="ms-SearchBox-icon ms-Icon ms-Icon--Search"></i>
</div>
<input class="ms-SearchBox-field" type="text" placeholder="Search"
v-model="searchQuery" ref="input"
#blur="onBlur" #focus="onFocus">
<div class="ms-SearchBox-clearButton" v-show="searchQuery.length > 0"
#click="clear">
<i class="ms-SearchBox-icon ms-Icon ms-Icon--Clear"></i>
</div>
</div>
SCSS
// Active styles
.ms-SearchBox.is-active {
.ms-SearchBox-iconContainer {
width: 4px;
transition: width .167s;
.ms-SearchBox-icon {
opacity: 0;
}
}
}
// Static styles
.ms-SearchBox {
display: inline-block;
font-size: 0px;
font-weight: 400;
color: #333;
border: 1px solid #a6a6a6;
height: 32px;
padding-left: 8px;
width: 208px;
.ms-SearchBox-iconContainer {
font-size: 14px;
color: #106ebe;
transition: width .167s;
.ms-SearchBox-icon {
opacity: 1;
transition: opacity .167s 0s;
}
background: rgba(0, 0, 0, 0.2);
}
.ms-SearchBox-field {
display: inline-block;
font-size: 14px;
margin: 0;
padding: 0;
text-overflow: ellipsis;
overflow: hidden;
border: none;
outline: 1px solid transparent;
height: 32px;
vertical-align: top;
background: rgba(255, 0, 0, 0.2);
}
.ms-SearchBox-iconContainer,
.ms-SearchBox-clearButton {
display: inline-block;
height: 32px;
line-height: 32px;
width: 32px;
text-align: center;
}
.ms-SearchBox-clearButton {
font-size: 14px;
background: rgba(0, 255, 0, 0.2);
&:hover {
cursor: pointer;
}
}
}
You should try to set a width:100% to your input, and to set position:absolute to your icon containers. With paddings on the input, this should do the thing.
Hope I understood the question :)

Styling input range lower in CSS for Webkit?

I am styling input[type=range] using CSS, and done with thumb and track.
All of three(-ms, -moz, -webkit) browser have proper prefix.
But, I don't know what vender prefix is suit to style progress on Webkit browser, such as Chrome.
On Internet Explorer and Microsoft Edge, -ms-fill-lower works great.
On Firefox, using -moz-range-progress solved the problem.
input[type=range] {
/*removes default webkit styles*/
-webkit-appearance: none;
/*fix for FF unable to apply focus style bug */
border: 1px solid white;
/*required for proper track sizing in FF*/
width: 350px;
}
/* Webkit, Chrome & Safari */
input[type=range]::-webkit-slider-runnable-track {
width: 300px;
height: 5px;
background: #ccc;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #004d66;
margin-top: -7px;
}
input[type=range]:focus {
outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #ddd;
}
/* moz://a Firefox */
input[type=range]::-moz-range-track {
/* width: 150px;
height: 5px; */
background: #ccc;
border: none;
border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #004d66;
}
input[type=range]::-moz-range-progress {
background: #33ccff;
border-radius: 10px;
height: 5px;
}
/*hide the outline behind the border*/
input[type=range]:-moz-focusring{
outline: 1px solid white;
outline-offset: -1px;
}
/* Microsoft */
input[type=range]::-ms-track {
height: 2px;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
background: transparent;
/*leave room for the larger thumb to overflow with a transparent border */
border-color: transparent;
border-width: 6px 0;
/*remove default tick marks*/
color: transparent;
}
input[type=range]::-ms-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #004d66;
margin-top: 1px;
}
input[type=range]::-ms-fill-lower {
background: #33ccff;
border-radius: 10px;
height: 5px;
}
input[type=range]::-ms-fill-upper {
background: #ccc;
border-radius: 10px;
}
input[type=range]:focus::-ms-fill-lower {
background: #44ddff;
}
input[type=range]:focus::-ms-fill-upper {
background: #ddd;
}
<input type="range" />
This example will work as I expected on Microsoft Edge, moz://a Firefox, and Internet Explorer, but looks differently on Chrome.
I already read Styling input range for webkit with pure CSS , and tried on mine,
but it works strangely when multiple input[type=range]s are on one document.
So, the question is,
Is there any proper vender prefix for styling track that thumb is already passed, only using CSS?
To the best of my knowledge, this isn't possible. Below is a snippet from Chrome showing the Shadow DOM elements for <input type="range" />:
<input type="range">
#shadow-root (user-agent)
<div style="-webkit-appearance:inherit">
<div pseudo="-webkit-slider-runnable-track" id="track">
<div id="thumb">
</div>
</div>
</div>
</input>
In general, you might want to take a look at range.css, it's a cross-browser code generator for custom range sliders. However, it doesn't provide a way to style the ::-moz-range-progress region. Other example's I've found, including this Codepen snippet, use the deprecated and no-longer-functional deep shadow-piercing selector. For a fully cross-browser solution, you'll have to make your own element.

Unexpected behavior of flex-positioned elements when manipulating text appearance on hover

I've been playing around with the flexbox properties to see what they can do:
display: flex;
flex-grow: n;
align-items: center;
justify-content: center;
However I've run into some unexpected behavior, and I'm hoping someone here can clarify for me. Manipulate one of the following properties of a flex-positioned element on the hover pseudo-selector:
text-size
font-weight
text-shadow
The elements' relative weights appear to be remeasured, so the elements' positions jump around. If you repeatedly hover back and forth between the top two or bottom two elements, you can reduce their weights to essentially zero. A jsfiddle to illustrate:
https://jsfiddle.net/b8bjv70f/8/
(And one with twice as many items: https://jsfiddle.net/b8bjv70f/9/)
And the corresponding code:
[HTML]
<div class="container">
<div class="item one">
Item 1
</div>
<div class="item two">
Item 2
</div>
<div class="item three">
Item 3
</div>
</div>
[CSS]
div.container {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
/* */
display: flex;
flex-direction: column;
justify-content: center;
}
div.item {
background-color: rgbA(0, 0, 0, 0.05); outline: 1px solid white;
/* */
display: flex;
flex-grow: 1;
align-items: center;
justify-content: center;
}
div.item a {
padding: 1em 2em;
font-family: 'sans-serif'; font-size: 1em;
text-transform: uppercase; text-decoration: none;
color: rgbA(150, 150, 150, 1.00); background-color: rgbA(255, 255, 255, 1.00); outline: 1px solid white;
}
div.one a:hover { text-shadow: 0 0 1em black; }
div.two a:hover { font-weight: bold; }
div.three a:hover { font-size: 1.5em; }
I didn't have the chance to test multiple environments before posting this question, but it turns out I can only to reproduce the odd behavior on Chrome OS, specifically build 48.0.2564.48 beta 64-bit. Standard Chrome 47 on Windows has no issues.
View the following recording to see what I'm seeing:
https://drive.google.com/file/d/0B6dJsjhml2eYb0thREc5S2J3Tnc/view
At this point I believe the issue is specific to Chrome OS or the Chrome beta channel. If I have the time, which is unlikely, I will investigate until I feel confident in submitting a Chromium issue to Google Code... otherwise, hopefully someone else will see this and pick up where I've left off.
I'll mark this as the accepted answer tomorrow, barring anyone else contributing a more comprehensive resolution in the meantime.

Resources