CSS module `:hover .child` not working - reactjs

I have the following scss:
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
&:hover {
padding: 3em;
.d-none {
display: inline-block !important;
}
}
&:hover .d-none {
display: inline-block !important;
}
}
On hover, I get the padding:3em but both the nested, and inline child rule didn't work, ie .d-none class wasn't overridden.
What's the right way of writing the rule with CSS module?
I'm trying out CSS module with CRA and custom-react-scripts with sass and modules turned on (REACT_APP_SASS_MODULES=true).
Or perhaps I should use styled components instead? Was trying to figure out which one to go for for react apps.

you can try this code to solve your problem
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 3em;
background: red;
&:hover {
&.d-none {
background: black;
color: #fff;
padding: 20px;
}
}
}
.d-none {
background: green;
color: #fff;
padding: 20px;
}
<div class="skillBox">
Parrent
<div class="d-none">Childred</div>
</div>
Exmaple :: https://codepen.io/anon/pen/yqQNJXCodePen

There's nothing wrong with your CSS. See the demo below.
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
.d-none{
display: none;
}
&:hover {
padding: 3em;
.d-none {
display: inline-block;
}
}
}
https://codepen.io/paulcredmond/pen/djQoow

In case if element with skillbox and d-none class are siblings below is the css for that
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
&:hover {
padding: 3em;
}
}
.dnone {
display: none;
}
.skillBox:hover ~ .dnone {
display: inline-block;
}
http://jsbin.com/hixamotuku/edit?html,css,output

So I realise CSS Modules created a customised classname for .d-none and applying that classname worked.
So I changed the classname altogether making it an entirely new class that overrides .d-none.
.skillBox {
position: relative;
border-radius: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 20px #ccc;
padding: 1em;
&:hover {
.dNone {
display: inline-block !important;
}
}
}
And applying by adding them as an array then joining them together:
<i className={['fas fa-times-circle d-none', styles.faTimesCircle, styles.dNone].join(' ')} onClick={this.onDelete} />

Related

Change ant design collapse content and header text color

How do I change the text color of the header and also for the content which is ant-collapse-content. I'm styling the AntCollapse using Styled and here's my code:
const StyledCollapse = styled(AntCollapse)`
&&& {
border: none;
border-radius: 0px;
box-shadow: none;
background: #0e0304;
}
.ant-collapse-content {
fontSize: 25px;
color: #fff;
}
.ant-collapse-header {
fontSize: 25px;
color: #fff;
}
`;
I tried using :global for both content and header but it didnt work as well.
try:
const StyledCollapse = styled(AntCollapse)`
&&& {
border: none;
border-radius: 0px;
box-shadow: none;
background: #0e0304;
}
&.ant-collapse-content {
fontSize: 25px;
color: #fff;
}
&.ant-collapse-header {
fontSize: 25px;
color: #fff;
}
`;

how to add error class on an input and override style with scss?

this is my css:
input[type="text"] {
.has-error {
color: red;
border: 1px solid red;
}
}
input[type="text"],
textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #446a63;
outline: none;
}
this is my react code:
<input
className={classNames({
"has-error": true,
})}
type="text"
placeholder="Name"
value={values.name}
onBlur={handleBlur("name")}
onChange={handleChange("name")}
/>
but that don't work, this does, but only changes the color and not override the border?, i want to override the border above of it and also nest it inside input type since it's only specific for inputs?:
input[type="text"],
textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #446a63;
outline: none;
}
.has-error {
color: red;
border: 1px solid red;
}
In CSS, the selector for input[type="text"] is more specific than one for just a css class as .has-error. Therefore the tag style overrides the class style (you should be able to see this in your dev console).
So you could fix your code with a more explicit selector, directly referencing both tag and class:
input[type="text"].has-error,textarea.has-error
input[type="text"],
textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #446a63;
outline: none;
}
input[type="text"].has-error,
textarea.has-error {
color: red;
border: 1px solid red;
}

Codename one TextComponent

trying to use the TextComponent but I failed to style it as shown in the image below;
TextComponent username = new TextComponent().labelAndHint("UserNmae").constraint(TextField.ANY);
FontImage.setMaterialIcon(username.getField().getHintLabel(), FontImage.MATERIAL_PERSON);
The TextComponent doesn't allow for that particular design at the time. The round border is pretty easy:
TextField {
border: 1pt solid blue;
border-radius: 0.5mm;
padding: 2mm;
}
But the text overlay that sits on the border itself is problematic with the current API. This is probably something that can be enhanced by adding another on-top mode to the TextComponent that would use CENTER_BEHAVIOR_TOTAL_BELOW for the BorderLayout there.
However, at this time we recommend using a slightly different design e.g.:
TextComponent login = new TextComponent().
label("Login").
descriptionMessage("Enter your email").
constraint(TextArea.EMAILADDR).
action(MATERIAL_ARROW_FORWARD).
actionClick(e ->
SigninStep2Form.create().show());
The CSS is:
#Constants {
includeNativeBool: true;
scrollVisibleBool: false;
labelGap: 2;
textComponentOnTopBool: true;
textComponentAnimBool: false;
textCmpVAlignInt: 0;
textComponentFieldUIID: TextComponentField;
}
Form {
background: white;
}
TextComponentField {
background: #EDEDED;
padding-left: 1mm;
padding-bottom: 1.5mm;
padding-top: 0.5mm;
padding-left: 3mm;
margin: 0px;
font-family: "native:MainRegular";
font-size: 3mm;
color: black;
border: none;
border-bottom: 0.25mm solid #9a9a9a;
}
InputComponentAction {
padding: 1mm;
background: transparent;
border: none;
}
FloatingHint {
font-family: "native:MainRegular";
font-size: 2mm;
color: #5e5e5e;
margin: 0px;
padding-top: 1.5mm;
padding-right: 1mm;
padding-bottom: 0px;
padding-left: 3mm;
background: #EDEDED;
border-top-left-radius: 1mm;
border-top-right-radius: 1mm;
}
TextComponent {
background: white;
border: none;
padding: 1mm;
margin: 0px;
}
ErrorLabel {
padding-top: 0.5mm;
background: transparent;
padding-left: 3mm;
}
DescriptionLabel {
padding-top: 0.5mm;
padding-left: 3mm;
background: transparent;
}
The resulting text components look like this:

Bootstrap dropdown is hidden behind other elements - Stacking Context issue

Boostrap dropdown is hidden inside other elements. When I try to click on pencil icon it shows dropdown but some other elements are overriding it. I made position of dropdown relative but it increases site of Div tag. attaching screenshot.
new
Christeen
Last modified 4-5-2016 at 23:16
Share
Edit
Delete
CSS
.listing-body ul.listbody {
margin: 0;
padding: 0;
display: block;
list-style: none;
}
.listing-body ul.listbody li {
margin: 0;
padding: 0;
list-style: none;
float: left;
width: 100%;
background: #FFF;
border: 1px solid #dadada;
border-top: none;
}
.listing-body .fourthli {
width: 25%;
float: left;
margin: 0;
padding: 0 1%;
color: #000;
font-family: 'robotoregular';
font-size: 12px;
line-height: 45px;
color: #333;
text-align: left;
box-sizing: border-box;
overflow: hidden;
max-width: 50%;
text-overflow: ellipsis;
white-space: nowrap;
}
.dropdown-menu {
position: absolute;
top: 100%;
right: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
list-style: none;
font-size: 14px;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
box-shadow: 0 6px 12px rgba(0,0,0,.175);
background-clip: padding-box;
}
The overflow:hidden in the .listing-body .fouthli was cropping off the dropdown menu. Removing it fixed it.

Tree built with Twitter Bootstrap and Backbone.js?

Is there a simple modular tree built with Twitter Bootstrap and Backbone.js that provides common tree control functionality?
Here's a Bootstrap tree widget (from "Trees in Twitter Bootstrap"):
Building on Vitaliy's CSS and Mehmet's jQuery, I changed the a tags to span tags and incorporated some Glyphicons and badging into my take on a Bootstrap tree widget.
Example:
For extra credit, I've created a GitHub project to host the jQuery and LESS code that goes into adding this tree component to Bootstrap. Please see the project documentation at http://jhfrench.github.io/bootstrap-tree/docs/example.html.
Alternately, here is the LESS source to generate that CSS (the JS can be picked up from the jsFiddle):
#import "../../../external/bootstrap/less/bootstrap.less"; /* substitute your path to the bootstrap.less file */
#import "../../../external/bootstrap/less/responsive.less"; /* optional; substitute your path to the responsive.less file */
/* collapsable tree */
.tree {
.border-radius(#baseBorderRadius);
.box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
background-color: lighten(#grayLighter, 5%);
border: 1px solid #grayLight;
margin-bottom: 10px;
max-height: 300px;
min-height: 20px;
overflow-y: auto;
padding: 19px;
a {
display: block;
overflow: hidden;
text-overflow: ellipsis;
width: 90%;
}
li {
list-style-type: none;
margin: 0px 0;
padding: 4px 0px 0px 2px;
position: relative;
&::before, &::after {
content: '';
left: -20px;
position: absolute;
right: auto;
}
&::before {
border-left: 1px solid #grayLight;
bottom: 50px;
height: 100%;
top: 0;
width: 1px;
}
&::after {
border-top: 1px solid #grayLight;
height: 20px;
top: 13px;
width: 23px;
}
span {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #grayLight;
border-radius: 5px;
display: inline-block;
line-height: 14px;
padding: 2px 4px;
text-decoration: none;
}
&.parent_li > span {
cursor: pointer;
/*Time for some hover effects*/
&:hover, &:hover+ul li span {
background: #grayLighter;
border: 1px solid #gray;
color: #000;
}
}
/*Remove connectors after last child*/
&:last-child::before {
height: 30px;
}
}
/*Remove connectors before root*/
> ul > li::before, > ul > li::after {
border: 0;
}
}
I recently published my backbone.js tree widget.Check it out at https://bitbucket.org/dnation/bbtree/ and see if it meets your needs.

Resources