I want to style the colors of a menu bar.
If the li is "active" then the text color and the border color should be blue, otherwise everything is gray.
On hover, the grey colors should turn blue.
I tried but it doesn't work. This is my code:
#import 'https://fonts.googleapis.com/css?family=Fjalla+One';
ul.dnav {
list-style-type: none;
margin-left: 0px;
margin-right: 0px;
overflow: hidden;
width: 400px;
-webkit-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
-moz-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
}
li.dnav {
font-size: 20px;
background-color: #FFF;
width: 100px;
float: left;
margin-top: 10px;
margin-right: 10px;
margin-left: 10px;
margin-bottom: 0px;
border-style: solid;
border-color: grey;
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
}
li.dnav a {
color: grey;
font-family: 'Fjalla One', sans-serif;
display: block;
text-align: center;
padding: 10px 10px;
text-decoration: none;
}
li.dnav a:hover {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
border-color: rgba(0, 130, 255, 1);
}
a:active {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
}
li.dnav-active {
border-color: rgba(0, 130, 255, 1);
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
color: rgba(0, 130, 255, 1);
}
<header>
<ul class="dnav">
<li class="dnav dnav-active"><a class="active" href="#">Home</a>
</li>
<li class="dnav">ser
</li>
<li class="dnav">con
</li>
</ul>
</header>
The problem is you are targeting the 'a' element in the hover selector.
The border is placed on the 'li' element instead.
So when you are hovering over the elemennt, only the border of the 'a' element is changing.
You could rewrite you're css to target the LI when hovering (as i did in the snippet), but i can recommend to fully style the 'a' element instead of the 'li'.
In the code snippet below the hover works with a small change to the 'hover' selector.
#import 'https://fonts.googleapis.com/css?family=Fjalla+One';
ul.dnav {
list-style-type: none;
margin-left: 0px;
margin-right: 0px;
overflow: hidden;
width: 400px;
-webkit-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
-moz-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
}
li.dnav {
font-size: 20px;
background-color: #FFF;
width: 100px;
float: left;
margin-top: 10px;
margin-right: 10px;
margin-left: 10px;
margin-bottom: 0px;
border-style: solid;
border-color: grey;
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
}
li.dnav a {
color: grey;
font-family: 'Fjalla One', sans-serif;
display: block;
text-align: center;
padding: 10px 10px;
text-decoration: none;
}
li.dnav:hover {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
border-color: rgba(0, 130, 255, 1);
}
a:active {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
}
li.dnav-active {
border-color: rgba(0, 130, 255, 1);
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
color: rgba(0, 130, 255, 1);
}
<header>
<ul class="dnav">
<li class="dnav dnav-active"><a class="active" href="#">Home</a>
</li>
<li class="dnav">ser
</li>
<li class="dnav">con
</li>
</ul>
</header>
You set up your hover rule only for the included a tag. I added a separate rule for the li element being hovered in the snippet below:
li.dnav:hover {
border-color: rgba(0, 130, 255, 1);
}
#import 'https://fonts.googleapis.com/css?family=Fjalla+One';
ul.dnav {
list-style-type: none;
margin-left: 0px;
margin-right: 0px;
overflow: hidden;
width: 400px;
-webkit-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
-moz-box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
box-shadow: 0px 5px 30px 8px rgba(128, 128, 128, 1);
}
li.dnav {
font-size: 20px;
background-color: #FFF;
width: 100px;
float: left;
margin-top: 10px;
margin-right: 10px;
margin-left: 10px;
margin-bottom: 0px;
border-style: solid;
border-color: grey;
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
}
li.dnav a {
color: grey;
font-family: 'Fjalla One', sans-serif;
display: block;
text-align: center;
padding: 10px 10px;
text-decoration: none;
}
li.dnav a:hover {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
border-color: rgba(0, 130, 255, 1);
}
li.dnav:hover {
border-color: rgba(0, 130, 255, 1);
}
a:active {
background-color: #fff;
opacity: 1;
overflow: hidden;
color: rgba(0, 130, 255, 1);
}
li.dnav-active {
border-color: rgba(0, 130, 255, 1);
border-bottom-width: 5px;
border-left-width: 0px;
border-top-width: 0px;
border-right-width: 0px;
color: rgba(0, 130, 255, 1);
}
<header>
<ul class="dnav">
<li class="dnav dnav-active"><a class="active" href="#">Home</a>
</li>
<li class="dnav">ser
</li>
<li class="dnav">con
</li>
</ul>
</header>
Related
When I change the container to be the class button1, I see the area around the button becoming orange, when I change that class to be send-message-button, it does not become green but rather white. I can add style to send-message-button if I do it within the html file but I am not sure as to why I can't do it using my styles.css file. Additionally, when I type class=", button1 shows up but not send-message-button.
.empty-text {
color: #777;
font-size: 1.5rem;
text-align: center;
}
.sent-message {
background-color: #15c6f7;
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: right;
}
.received-message {
background-color: rgb(201, 206, 208);
color: rgb(90, 124, 92);
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: left;
}
.send-message-button {
background-color: #2ce168;
border-color: #2ce168;
color: white
}
.button1 {
background-color: #e1862c;
border-color: #e1862c;
color: white
}
.card-infoDisplay {
background-color: #e1862c;
border-color: #e1862c;
}
.real-name {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.user-major {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.titleDiv {
height: 1rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 10px;
}
.sectionDiv {
height: 0.25rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 20px;
}
.searchDiv {
display: flex;
justify-content: center;
padding-bottom: 20px;
gap: 20px;
}
<div class="send-message-button">
<button class="btn btn-light" type="submit">Send Message</button>
</div>
Is this what you want it to look like?
.empty-text {
color: #777;
font-size: 1.5rem;
text-align: center;
}
.sent-message {
background-color: #15c6f7;
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: right;
}
.received-message {
background-color: rgb(201, 206, 208);
color: rgb(90, 124, 92);
border-radius: 30px;
padding: 10px 25px;
width: 25%;
float: left;
}
.send-message-button {
color: white
}
.btn.btn-light {
background-color: #2ce168;
border-color: #2ce168;
}
.button1 {
background-color: #e1862c;
border-color: #e1862c;
color: white
}
.card-infoDisplay {
background-color: #e1862c;
border-color: #e1862c;
}
.real-name {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.user-major {
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
}
.titleDiv {
height: 1rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 10px;
}
.sectionDiv {
height: 0.25rem;
background-color: rgba(500, 0, 0, .1);
border: solid rgba(0, 0, 0, .15);
border-width: 1px 0;
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
margin-top: 20px;
margin-bottom: 20px;
}
.searchDiv {
display: flex;
justify-content: center;
padding-bottom: 20px;
gap: 20px;
}
<div class="send-message-button">
<button class="btn btn-light" type="submit">Send Message</button>
</div>
I am creating a dropdown box for the account at the top right corner of the window.
I have added the code for the :before but does not seem to show above the element. The :before element is meant to be a triangle at the top of the ul container which points to where the dropdown has come from.
.DropDownContainer{
color: rgba(0, 0, 0, 0.87);
background-color: rgb(255, 255, 255);
transition: transform 250ms cubic-bezier(0.23, 1, 0.32, 1) 0ms, opacity 250ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
box-sizing: border-box;
font-family: Roboto, sans-serif;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 6px, rgba(0, 0, 0, 0.12) 0px 1px 4px;
border-radius: 2px;
position: fixed;
z-index: 2100;
opacity: 1;
transform: scale(1, 1);
transform-origin: left top;
max-height: 670px;
overflow-y: auto;
float: left;
text-align: left;
top: 55px;
right: 20px;
padding: 26px 0;
border-radius: 8px;
position: absolute;
top: calc(60px - 10px);
width: 210px;
list-style: none;
background-clip: padding-box;
padding-left:0;
}
.DropDownContainer:before{
content: '';
width: 0;
height: 0;
position: absolute;
top: -20px;
right: 120px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
}
.DropDownButton{
display: flex;
justify-content: left;
padding: 10px;
padding-left: 28px;
padding-right: 28px;
letter-spacing: 1px;
color: rgb(38, 38, 38);
}
.DropDownButton a{
text-decoration: none;
}
.DropDownButton img{
height: 20px;
width: 20px;
margin-right: 10px;
}
.DropDownButton:hover{
background-color: rgba(36, 36, 36, 0.071);
cursor: pointer;
}
(<ul className={classes.DropDownContainer}>
<li className={classes.DropDownButton} onClick={() => setShowDropDown(false)}>Profile</li>
<li className={classes.DropDownButton}>Edit Profile</li>
<li className={classes.DropDownButton}>My Hub</li>
<li className={classes.DropDownButton} >My Favourites</li>
<li className={classes.DropDownButton} >My Must Reads</li>
<li className={classes.DropDownButton}>Account Settings</li>
<li className={classes.DropDownButton} >Sign Out</li>
</ul>)
It is meant to be a triangle at the top of the ul container.
You should write two colons not only a colon for ' before '. I mean your code should be as such :
.DropDownContainer::before {
content: '';
width: 0;
height: 0;
position: absolute;
top: -20px;
right: 120px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #fff;
}
There are two buttons in my sidebar. I want to make my button blue when it's clicked and to remain blue until the other button is clicked. It shouldn't change back to the old color when we click on the body or anywhere else but only when I click the other button.
It would also be nice if someone can show me if those sidebar buttons to turn white again when clicked on the create new button on the navbar.
code sandbox https://codesandbox.io/s/sweet-feynman-2tvy5
css for the buttons
.sideButton {
width: 200px;
height: 50px;
padding-left: 0px;
margin-left: 0px;
padding: 0;
border: none;
font: inherit;
color: inherit;
border-radius: 0 10px 10px 0;
background-color: rgba(191, 191, 191, 0.14);
box-shadow: inset 0 1px 10px 0 rgba(0, 0, 0, 0.15);
position: absolute;
left: 0;
right: 0;
cursor: pointer;
-webkit-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
-moz-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.1);
}
.sideButton:focus,
.sideButton:active,
.sideButton.active {
background-color: blue;
}
.sideButton2 {
width: 200px;
height: 50px;
padding-left: 0px;
margin-left: 0px;
margin-top: 55px;
padding: 0;
border: none;
font: inherit;
color: inherit;
border-radius: 0 10px 10px 0;
background-color: white;
box-shadow: inset 0 1px 10px 0 rgba(0, 0, 0, 0.15);
position: absolute;
left: 0;
right: 0;
cursor: pointer;
-webkit-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
-moz-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.1);
}
.sideButton2:focus,
.sideButton2:active,
.sideButton2.active {
background-color: blue;
}
the react files where the button is located
import React, { Component } from "react";
import { BrowserRouter as Router, Route, Switch, Link } from "react-router-dom";
import { Nav, Button } from "react-bootstrap";
import "../App.css";
export default class LeftBox extends Component {
constructor(props) {
super(props);
}
render() {
return (
<>
<div className="nav">
<ul>
<li className="list-item">
<Link to="/about">
<input
type="button"
className="sideButton sideBarText"
value="Dashboard"
/>
</Link>
</li>
<li className="list-item">
<Link to="/">
<input
type="button"
className="sideButton2 sideBarText2"
value="People"
/>
</Link>
</li>
</ul>
</div>
</>
);
}
}
You can create your own kind of link that would be in sync with url
import {
Link,
withRouter
} from "react-router-dom";
function NavInput({ value, className, to, location }) {
let isActive = to === location.pathname;
return (
<Link to={to}>
<input
type="button"
className={className + (isActive ? " active" : "")}
value={value}
/>
</Link>
);
}
const NavInputLink = withRouter(NavInput);
and then your leftBox.js would be
export default class LeftBox extends Component {
constructor(props) {
super(props);
}
render() {
return (
<>
<div className="nav">
<ul>
<li className="list-item">
<NavInputLink
to="/about"
value="Dashboard"
className="sideButton sideBarText"
/>
</li>
<li className="list-item">
<NavInputLink
to="/"
value="People"
className="sideButton2 sideBarText2"
/>
</li>
</ul>
</div>
</>
);
}
}
Please check https://codesandbox.io/s/cool-firefly-cq0hr
the easiest way to make this possible is using NavLink
leftBox.js
import React, { Component } from "react";
import {
BrowserRouter as Router,
Route,
Switch,
NavLink
} from "react-router-dom";
import { Nav, Button } from "react-bootstrap";
import "../App.css";
export default class LeftBox extends Component {
constructor(props) {
super(props);
this.state = {
button: false
};
}
render() {
return (
<>
<div className="nav">
<ul>
<li className="list-item">
<NavLink
to="/about"
className="sideButton"
activeClassName="active_navbar"
exact
>
Dashboard
</NavLink>
</li>
<li className="list-item">
<NavLink
to="/"
className="sideButton2"
activeClassName="active_navbar"
exact
>
People
</NavLink>
</li>
</ul>
</div>
</>
);
}
}
Change CSS
.sideButton {
width: 200px;
height: 50px;
padding-left: 0px;
margin-left: 0px;
padding: 0;
border: none;
font: inherit;
color: inherit;
border-radius: 0 10px 10px 0;
background-color: rgba(191, 191, 191, 0.14);
box-shadow: inset 0 1px 10px 0 rgba(0, 0, 0, 0.15);
position: absolute;
left: 0;
right: 0;
/* show a hand cursor on hover; some argue that we
should keep the default arrow cursor for buttons */
cursor: pointer;
-webkit-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
-moz-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.1);
}
.sideButton:focus,
.sideButton:active,
.sideButton.active {
/* background-color: rgba(191, 191, 191, 0.14); */
background-color: blue;
}
.sideButton:selected {
background-color: #007bff;
}
.sideButton2 {
width: 200px;
height: 50px;
padding-left: 0px;
margin-left: 0px;
margin-top: 55px;
padding: 0;
border: none;
font: inherit;
color: inherit;
border-radius: 0 10px 10px 0;
background-color: white;
box-shadow: inset 0 1px 10px 0 rgba(0, 0, 0, 0.15);
position: absolute;
left: 0;
right: 0;
cursor: pointer;
-webkit-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
-moz-box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.17);
box-shadow: inset 0px -1px 28px -1px rgba(0, 0, 0, 0.1);
}
.sideButton2:focus,
.sideButton2:active,
.sideButton2.active {
/* background-color: rgba(191, 191, 191, 0.14); */
background-color: blue;
}
.active_navbar {
background-color: blue;
}
.leftMain {
display: flex;
flex-direction: row;
padding-top: 40px;
}
.rightMain {
display: flex;
padding-top: 20px;
}
ul {
list-style: none;
}
.navbar {
position: fixed;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.7rem 2rem;
overflow: hidden;
z-index: 1;
width: 80%;
margin: auto;
top: 0;
border-bottom: solid 1px var(--primary-color);
opacity: 0.9;
position: relative;
top: 0;
/* box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.25); */
box-shadow: 12px 0 15px -4px rgba(31, 73, 125, 0.8),
-12px 0 8px -4px rgba(31, 73, 125, 0.8);
box-shadow: 0 9px 0px 0px white, 0 -9px 0px 0px white,
12px 0 15px -4px rgba(31, 73, 125, 0.8),
-12px 0 15px -4px rgba(31, 73, 125, 0.8);
}
.navbar ul {
display: flex;
}
.navbar a {
color: #2076d9;
padding: 0.45rem;
margin: 0 0.25rem;
}
.navbar a:hover {
color: var(--primary-color);
}
.navbar .welcome span {
margin-right: 0.6rem;
}
/* dashButton {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
dashButton::after {
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
opacity: 0;
transition: opacity 0.3s ease-in-out;
} */
#media (min-width: 768px) #dashboardpills .nav-item .nav-link {
max-height: 42px;
opacity: 0.25;
color: #000;
font-family: Poppins;
font-size: 30px;
font-weight: 700;
line-height: 42px;
}
a:not([href]):not([tabindex]) {
color: inherit;
text-decoration: none;
}
.nav-pills .nav-link {
border-radius: 0.25rem;
}
.nav-link {
display: block;
padding: 0.5rem 1rem;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
*,
::after,
::before {
box-sizing: border-box;
}
user agent stylesheet li {
text-align: -webkit-match-parent;
}
.nav {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
.titleName {
font-family: Poppins;
}
.sideBarText {
color: #000;
font-family: Poppins;
font-size: 18px;
font-weight: 600;
line-height: 25px;
}
.sideBarText2 {
color: #000;
font-family: Poppins;
font-size: 18px;
font-weight: 600;
line-height: 25px;
}
.createNew {
height: 40px;
width: 153px;
border: 0px;
border-radius: 10px;
/* background-color: #2076d9; */
background-image: linear-gradient(
to top,
#d83f91,
#d0409b,
#c743a5,
#bb47af,
#ae4bb8
);
box-shadow: 0 2px 20px 0 rgba(0, 0, 0, 0.25);
}
.signOut {
border: 0px;
height: 40px;
width: 100px;
border-radius: 10px;
background-image: linear-gradient(
to right,
#eb3941,
#f15e64,
#e14e53,
#e2373f
);
box-shadow: 0 5px 15px rgba(242, 97, 103, 0.4);
box-shadow: 0 2px 20px 0 rgba(0, 0, 0, 0.25);
}
.mainCom {
height: 56px;
width: 68px;
color: #000;
font-family: Poppins;
font-size: 40px;
font-weight: 700;
line-height: 56px;
left: 0;
cursor: pointer;
}
.mainComS {
height: 42px;
width: 255px;
opacity: 0.25;
color: #000;
font-family: Poppins;
font-size: 24px;
font-weight: 700;
line-height: 42px;
cursor: pointer;
}
.mainComS2 {
height: 42px;
width: 200px;
opacity: 0.25;
color: #000;
font-family: Poppins;
text-align: center;
font-size: 24px;
font-weight: 700;
line-height: 42px;
cursor: pointer;
}
.conMain {
height: 130vh;
margin-top: 20px;
width: 100%;
box-shadow: 12px 0 15px -4px rgba(31, 73, 125, 0.8),
-12px 0 8px -4px rgba(31, 73, 125, 0.8);
box-shadow: 0 9px 0px 0px white, 0 -9px 0px 0px white,
12px 0 15px -4px rgba(31, 73, 125, 0.8),
-12px 0 15px -4px rgba(31, 73, 125, 0.8);
}
ul {
list-style: none;
}
li:hover {
cursor: pointer;
}
You will get your all solution in it
You can change your class dynamically. Hitt the upvote if use like it.
$(document).ready(function(){
$("li").click(function() {
if($(this).siblings('li').find('input').hasClass('active')) {
$(this).siblings('li').find('input').removeClass('active');
$(this).find('input').addClass('active');
}
});
});
li {
list-style: none;
padding-right: 20px;
display: inline-block;
}
li .btn {
padding: 7px 20px;
background: #fff;
border: 1px solid #000;
font-size: 16px;
color: #000;
outline: none;
}
li .btn.active {
color: #fff;
background: #000;
border: 1px solid #000;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrap">
<ul>
<li>
<input class="btn active" type="button" name="Button 1" value="btn1">
</li>
<li>
<input class="btn" type="button" name="Button 3" value="btn2">
</li>
</ul>
</div>
Well, one of your ways to accomplish this, you can do is, make a state in your class, like:
state={mycolor:"red"};
And your button be like:
<button style={{color:this.state.mycolor}}
onClick={()=>this.colorhandler()}>click here</button>
And in your class define your colorhandler
colorhandler(){
this.setState({mycolor:"blue"});
}
And when you click on the button the color will change,
hope you get the idea and works for you
update
If you want keep your CSS files you can change code like this:
state={myclassname:"btn active"};
< button class={ this.state.myclassname}
onClick={ ()=>this.Classhandler()}> click here </ button>
Classhandler(){
this.setState({myclassname:"btn deactive"});
}
Hopefully somebody can help me with my issue.
I'm trying to make my own website, but when I try to move one of the three individual boxes(see picture), all three of them move. three boxes issue
[The same issue also happens with the social icons box but I'm less concerned with that section]
I'm hoping someone can take a look at the code and hopefully tell me where I've gone wrong.
My Website Files
You have put position:block in your css. There is no position:block in css. You have to use display property to that. I have change your box div's css to display: inline-block; and made few changes in width too.(using calc).
#import url('https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Source+Sans+Pro');
#import url('https://fonts.googleapis.com/css?family=Poppins');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-image: url(../css/images/background/backgroundimage.jpg);
}
/* HEADERBAR */
div#headerbar {
width: 100%;
height: 50px;
display: inline-block;
background-color: rgba(237,87,82, 0.65);
font-family: 'Source Sans Pro', sans-serif;
box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 2px #000000;
-webkit-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
-moz-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
-o-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
}
.leftlogo {
float: left;
margin-top: 12px;
margin-left: 15px;
color: #fff;
text-shadow: 1px 1px 1px #000;
font-size: 20px;
font-family: 'roboto+condensed', sans-serif;
}
.leftlogo span {
font-weight: 300;
color: rgba(237, 87, 82, 0.8);
font-size: 20px;
font-family: 'roboto', sans-serif;
}
.version {
float: right;
margin-top: 14px;
margin-right: 10px;
}
/* CODE TEST */
.box {
width: 40%;
margin: 0 auto;
background: rgba(255,255,255,0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 21px/40px;
background-clip: padding-box;
text-align: center;
}
.button {
margin-top: 10px;
font-size: 1em;
padding: 14px;
color: #fff;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
font-family: 'Source Sans Pro', sans-serif;
}
.button:hover {
background: rgba(255, 255, 255, 0.3);
border: 3px solid #000;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #000;
border-radius: 5px;
border: 5px solid #126b72;
width: 70%;
position: relative;
transition: all 5s ease-in-out;
color: #fff;
font-family: 'Roboto Condensed', sans-serif;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
#media screen and (max-width: 700px){
.box{
width: 70%;
}
.popup{
width: 70%;
}
}
div#updatesbox {
width: 900px;
height: 40px;
background-color: #000;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 2px #000000;
}
.updatesbox1 {
width: 443px;
height: 30px;
background-color: rgba(255, 255, 255, 0.2);
display:inline-block;
margin-top: 5px;
margin-left: 5px;
box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 2px #000000;
-webkit-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
-moz-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
-o-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
}
.updatesbox2 {
width: 443px;
height: 30px;
background-color: rgba(255, 255, 255, 0.2);
float: right;
display: inline-block;
margin-top: 5px;
margin-right: 5px;
box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 2px #000000;
-webkit-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
-moz-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
-o-box-shadow: inset 0px 0px 20px 0px #000000,2px 2px 20px 6px #000000;
}
.twitter {
float: left;
margin-top: 7px;
margin-left: 40px;
}
.tweet {
color: white;
}
.facebook a {
color: rgba(273, 87, 84, 1);
text-decoration: none;
font-family: 'Poppins', sans-serif;
}
.facebookicon {
margin-left: 5px;
margin-top: 7px;
}
.steam a {
color: rgba(273, 87, 84, 1);
text-decoration: none;
font-family: 'Poppins', sans-serif;
}
.steamicon {
margin-left: 5px;
margin-top: 7px;
}
.instagram a {
color: rgba(273, 87, 84, 1);
text-decoration: none;
font-family: 'Poppins', sans-serif;
}
.instaicon {
margin-left: 5px;
margin-top: 7px;
}
.tweet a {
color: rgba(237, 87, 84, 1);
text-decoration: none;
font-family: 'Poppins', sans-serif;
}
/* ALTERNATING TEXT */
#tickertape{
display: block;
margin-left: 600px;
margin-right: auto;
margin-top: 14.5px;
text-align: center;
width:400px;
height:20px;
}
.tickertape {
display: block;
margin-top: 6px;
margin-left: 20px;
margin-right: auto;
color: #000;
}
#subtickertape{
position:absolute;
width:443px;
height:20px;
}
.subtickertapefont{
font:bold 12px Verdana;
text-decoration:none;
color: rgba(237, 87, 84, 0.6);
text-shadow: 2px 2px 2px #000;
}
.subtickertapefont a{
color:white;
text-decoration:none;
}
/* BODY CONTAINER BOX */
div#bodycontainer {
margin-top: 20px;
margin-left: auto;
margin-right: auto;
background-color: rgba(237, 87, 84, 0.3);
width: 90%;
height: 800px;
border: 2px dashed #000;
}
#bodycontainer #insidebox {
display: inline-block;
float: left;
width: calc(32.3% - 7.5px);
height: 500px;
margin: 15px;
margin-top: 70px;
background: rgba(237, 87, 84, 0.2);
border: 2px dashed #000;
}
#bodycontainer #centerbox {
display: inline-block;
float: left;
width: calc(32.3% - 7.5px);
height: 400px;
margin: auto;
margin-top: 200px;
background: rgba(255, 255, 255, 0.2);
border: 2px dashed #000;
}
#rightbox {
display: inline-block;
float: left;
width: calc(32.3% - 7.5px);
height: 710px;
margin: auto;
margin-top: 0px;
background: rgba(237, 87, 84, 0.2);
border: 2px dashed #000;
margin-left: 15px !important;
}
change your stylesheet.css to this and then you can move each box individually. Hope this helps you.
I want to center-align the text in the span. Why does it only work in Chrome, but no IE?
.txt {
align-items: center;
background-color: rgba(0, 0, 0, 0.0980392);
background-image: none;
border-bottom-color: rgba(0, 0, 0, 0.117647);
border-bottom-style: solid;
border-bottom-width: 1px;
border-collapse: collapse;
border-image-outset: 0px;
border-image-repeat: stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgba(0, 0, 0, 0.117647);
border-left-style: solid;
border-left-width: 1px;
border-right-color: rgba(0, 0, 0, 0.117647);
border-right-style: solid;
border-right-width: 1px;
border-top-color: rgba(0, 0, 0, 0.117647);
border-top-style: solid;
border-top-width: 1px;
box-shadow: none;
box-sizing: border-box;
color: rgb(0, 0, 0);
cursor: default;
display: flex;
fill: rgb(0, 0, 0);
float: left;
font-family: MetricWeb-Medium, arial;
font-size: 16px;
height: 48px;
justify-content: center;
line-height: 16px;
margin-bottom: 1.54688px;
margin-left: 1.54688px;
margin-right: 1.54688px;
margin-top: 1.54688px;
outline-color: rgb(0, 0, 0);
outline-style: none;
outline-width: 0px;
padding-bottom: 6px;
padding-left: 12px;
padding-right: 12px;
padding-top: 6px;
text-align: center;
white-space: nowrap;
width: 35.875px;
-webkit-user-select: none;
}
<span class="txt">2016</span>
https://jsfiddle.net/ramseyfeng/fd5sxv27/
The problem is the way each browser renders the left and right padding.
In your code you have:
.txt {
padding-left: 12px;
padding-right: 12px;
}
Chrome basically ignores this padding when centering the text in the small container:
But IE11 respects the padding:
The solution is to simply remove the horizontal padding:
.txt {
padding-left: 0;
padding-right: 0;
}
Revised Fiddle
I made an amendment to your jsfiddle;
Your font-size will not work with the padding you've selected with the font-size. Padding-Left was causing the off-center shift from the left side. Also your box is way too small for the font-size of 16 pts.
Jsfiddle Change ver5 - Removed padding all together, keeping the same font-size, and increased width to 70px.
Jsfiddle Change ver6 - Reduced Font Size to 12px from 16 and padding left and right reduced to 3px from 6px & 12px.
https://jsfiddle.net/fd5sxv27/5/
.txt {
align-items: center;
background-color: rgba(0, 0, 0, 0.0980392);
background-image: none;
border-bottom-color: rgba(0, 0, 0, 0.117647);
border-bottom-style: solid;
border-bottom-width: 1px;
border-collapse: collapse;
border-image-outset: 0px;
border-image-repeat: stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgba(0, 0, 0, 0.117647);
border-left-style: solid;
border-left-width: 1px;
border-right-color: rgba(0, 0, 0, 0.117647);
border-right-style: solid;
border-right-width: 1px;
border-top-color: rgba(0, 0, 0, 0.117647);
border-top-style: solid;
border-top-width: 1px;
box-shadow: none;
box-sizing: border-box;
color: rgb(0, 0, 0);
cursor: default;
display: flex;
fill: rgb(0, 0, 0);
float: left;
font-family: MetricWeb-Medium, arial;
font-size: 16px;
height: 48px;
justify-content: center;
line-height: 16px;
margin-bottom: 1.54688px;
margin-left: 1.54688px;
margin-right: 1.54688px;
margin-top: 1.54688px;
outline-color: rgb(0, 0, 0);
outline-style: none;
outline-width: 0px;
text-align: center;
white-space: nowrap;
width: 70px;
-webkit-user-select: none;
}
https://jsfiddle.net/fd5sxv27/6/
.txt {
align-items: center;
background-color: rgba(0, 0, 0, 0.0980392);
background-image: none;
border-bottom-color: rgba(0, 0, 0, 0.117647);
border-bottom-style: solid;
border-bottom-width: 1px;
border-collapse: collapse;
border-image-outset: 0px;
border-image-repeat: stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgba(0, 0, 0, 0.117647);
border-left-style: solid;
border-left-width: 1px;
border-right-color: rgba(0, 0, 0, 0.117647);
border-right-style: solid;
border-right-width: 1px;
border-top-color: rgba(0, 0, 0, 0.117647);
border-top-style: solid;
border-top-width: 1px;
box-shadow: none;
box-sizing: border-box;
color: rgb(0, 0, 0);
cursor: default;
display: flex;
fill: rgb(0, 0, 0);
float: left;
font-family: MetricWeb-Medium, arial;
font-size: 12px;
height: 48px;
justify-content: center;
line-height: 16px;
margin-bottom: 1.54688px;
margin-left: 1.54688px;
margin-right: 1.54688px;
margin-top: 1.54688px;
outline-color: rgb(0, 0, 0);
outline-style: none;
outline-width: 0px;
padding-bottom: 3px;
padding-left: 3px;
padding-right: 12px;
padding-top: 6px;
text-align: center;
white-space: nowrap;
width: 35.875px;
-webkit-user-select: none;
}