I want to reduce the width and height of the box of my datetime picker. This is the image from my dateTimePicker.
And this is my component:
import React,{useState} from 'react';
import momentLocaliser from 'react-widgets-moment';
import DateTime from 'react-datetime';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import 'react-datetime/css/react-datetime.css';
const moment = require('moment');
moment.locale('es');
momentLocaliser(moment);
const DateTimePickerInput = ({
label,
format,
input,
width,
placeholder,
selected,
tooltip,
tooltipPlacement,
disabled,
defaultValue,
value,
onChange,
inputProps,
meta: { valid, touched, error},
showTime,
style,
...props
}) => {
const classes = classNames('form-group', {
'has-error': (touched && !valid),
'has-success': (touched && !valid)
})
return (
<div className={classes}>
<label htmlFor={input.name}>{label}</label> <br />
<DateTime
name = {input.name}
locale='es'
dateFormat= "DD-MM-YYYY"
timeFormat= "HH:mm:ss"
onChange={param => {
input.onChange(param)
}}
inputProps={{placeholder: !input.value ? 'Please, select a date': moment(input.value).format('DD-MM-YYYY HH:mm:ss')/*,disabled: true}*/}}
style={{}}
{(!valid && touched) &&
<p className='help-block'>{error}</p>
}
</div>
);
};
DateTimePickerInput.propTypes = {
disabled: PropTypes.bool,
input: PropTypes.object.isRequired,
label: PropTypes.string.isRequired,
meta: PropTypes.object.isRequired,
placeholder: PropTypes.string,
tooltip: PropTypes.string,
tooltipPlacement: PropTypes.string
}
export default DateTimePickerInput;
And this is my style sheet, the style sheet I'm importing from my DateTimePicker widget:
/*!
https://github.com/YouCanBookMe/react-datetime
*/
.rdt {
position: relative;
}
.rdtPicker {
display: none;
position: absolute;
width: 250px;
padding: 4px;
margin-top: 1px;
z-index: 99999 !important;
background: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
border: 1px solid #f9f9f9;
}
.rdtOpen .rdtPicker {
display: block;
}
.rdtStatic .rdtPicker {
box-shadow: none;
position: static;
}
.rdtPicker .rdtTimeToggle {
text-align: center;
}
.rdtPicker table {
width: 100%;
margin: 0;
}
.rdtPicker td,
.rdtPicker th {
text-align: center;
height: 28px;
}
.rdtPicker td {
cursor: pointer;
}
.rdtPicker td.rdtDay:hover,
.rdtPicker td.rdtHour:hover,
.rdtPicker td.rdtMinute:hover,
.rdtPicker td.rdtSecond:hover,
.rdtPicker .rdtTimeToggle:hover {
background: #eeeeee;
cursor: pointer;
}
.rdtPicker td.rdtOld,
.rdtPicker td.rdtNew {
color: #999999;
}
.rdtPicker td.rdtToday {
position: relative;
}
.rdtPicker td.rdtToday:before {
content: '';
display: inline-block;
border-left: 7px solid transparent;
border-bottom: 7px solid #428bca;
border-top-color: rgba(0, 0, 0, 0.2);
position: absolute;
bottom: 4px;
right: 4px;
}
.rdtPicker td.rdtActive,
.rdtPicker td.rdtActive:hover {
background-color: #428bca;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.rdtPicker td.rdtActive.rdtToday:before {
border-bottom-color: #fff;
}
.rdtPicker td.rdtDisabled,
.rdtPicker td.rdtDisabled:hover {
background: none;
color: #999999;
cursor: not-allowed;
}
.rdtPicker td span.rdtOld {
color: #999999;
}
.rdtPicker td span.rdtDisabled,
.rdtPicker td span.rdtDisabled:hover {
background: none;
color: #999999;
cursor: not-allowed;
}
.rdtPicker th {
border-bottom: 1px solid #f9f9f9;
}
.rdtPicker .dow {
width: 14.2857%;
border-bottom: none;
cursor: default;
}
.rdtPicker th.rdtSwitch {
width: 100px;
}
.rdtPicker th.rdtNext,
.rdtPicker th.rdtPrev {
font-size: 21px;
vertical-align: top;
}
.rdtPrev span,
.rdtNext span {
display: block;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none;
}
.rdtPicker th.rdtDisabled,
.rdtPicker th.rdtDisabled:hover {
background: none;
color: #999999;
cursor: not-allowed;
}
.rdtPicker thead tr:first-child th {
cursor: pointer;
}
.rdtPicker thead tr:first-child th:hover {
background: #eeeeee;
}
.rdtPicker tfoot {
border-top: 1px solid #f9f9f9;
}
.rdtPicker button {
border: none;
background: none;
cursor: pointer;
}
.rdtPicker button:hover {
background-color: #eee;
}
.rdtPicker thead button {
width: 100%;
height: 100%;
}
td.rdtMonth,
td.rdtYear {
height: 50px;
width: 25%;
cursor: pointer;
}
td.rdtMonth:hover,
td.rdtYear:hover {
background: #eee;
}
.rdtCounters {
display: inline-block;
}
.rdtCounters > div {
float: left;
}
.rdtCounter {
height: 100px;
}
.rdtCounter {
width: 40px;
}
.rdtCounterSeparator {
line-height: 100px;
}
.rdtCounter .rdtBtn {
height: 40%;
line-height: 40px;
cursor: pointer;
display: block;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none;
}
.rdtCounter .rdtBtn:hover {
background: #eee;
}
.rdtCounter .rdtCount {
height: 20%;
font-size: 1.2em;
}
.rdtMilli {
vertical-align: middle;
padding-left: 8px;
width: 48px;
}
.rdtMilli input {
width: 100%;
font-size: 1.2em;
margin-top: 37px;
}
.rdtTime td {
cursor: default;
}
I'm using react-datetime as dependency. The box of the widget has too big width and I need to reduce the width of the box. How can I reduce the width of the box of my date time picker?
Override the CSS rules of react-datetime like the following:
.rdtPicker {
width: 400px; //Change it your preferred width
}
.rdtPicker tr {
height: 50px; //Choose the height of each row so that the overall height will change
}
Here's a working pen.
Related
I am using NextJS and making a calendar component. Issue is I am trying to override the Calendar.css file in the module that it says you can override to make custom styles. I have overridden it my own styles but they aren't taking effect. Then I tried deleting the css file content entirely but it didn't even change the format. It wasn't until I comment out the import css that the style goes back to normal. Is this a React 18/Nextjs bug? I tried it in chrome and firefox and got the same results.
The first picture is a screenshot of what is displayed after applying the default css styling in the module. The second picture is what I would like it to look like after overriding the default css file.
.react-calendar {
width: 350px;
max-width: 100%;
background: white;
border: 1px solid #a0a096;
font-family: Arial, Helvetica, sans-serif;
line-height: 1.125em;
}
.react-calendar--doubleView {
width: 700px;
}
.react-calendar--doubleView .react-calendar__viewContainer {
display: flex;
margin: -0.5em;
}
.react-calendar--doubleView .react-calendar__viewContainer > * {
width: 50%;
margin: 0.5em;
}
.react-calendar,
.react-calendar *,
.react-calendar *:before,
.react-calendar *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.react-calendar button {
margin: 0;
border: 0;
outline: none;
}
.react-calendar button:enabled:hover {
cursor: pointer;
}
.react-calendar__navigation {
display: flex;
height: 44px;
margin-bottom: 1em;
}
.react-calendar__navigation button {
min-width: 44px;
background: none;
}
.react-calendar__navigation button:disabled {
background-color: #f0f0f0;
}
.react-calendar__navigation button:enabled:hover,
.react-calendar__navigation button:enabled:focus {
background-color: #e6e6e6;
}
.react-calendar__month-view__weekdays {
text-align: center;
text-transform: uppercase;
font-weight: bold;
font-size: 0.75em;
}
.react-calendar__month-view__weekdays__weekday {
padding: 0.5em;
}
.react-calendar__month-view__weekNumbers .react-calendar__tile {
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75em;
font-weight: bold;
}
.react-calendar__month-view__days__day--weekend {
color: #d10000;
}
.react-calendar__month-view__days__day--neighboringMonth {
color: #757575;
}
.react-calendar__year-view .react-calendar__tile,
.react-calendar__decade-view .react-calendar__tile,
.react-calendar__century-view .react-calendar__tile {
padding: 2em 0.5em;
}
.react-calendar__tile {
max-width: 100%;
padding: 10px 6.6667px;
background: none;
text-align: center;
line-height: 16px;
}
.react-calendar__tile:disabled {
background-color: #f0f0f0;
}
.react-calendar__tile:enabled:hover,
.react-calendar__tile:enabled:focus {
background-color: #e6e6e6;
}
.react-calendar__tile--now {
background: #ffff76;
}
.react-calendar__tile--now:enabled:hover,
.react-calendar__tile--now:enabled:focus {
background: #ffffa9;
}
.react-calendar__tile--hasActive {
background: #76baff;
}
.react-calendar__tile--hasActive:enabled:hover,
.react-calendar__tile--hasActive:enabled:focus {
background: #a9d4ff;
}
.react-calendar__tile--active {
background: #006edc;
color: white;
}
.react-calendar__tile--active:enabled:hover,
.react-calendar__tile--active:enabled:focus {
background: #1087ff;
}
.react-calendar--selectRange .react-calendar__tile--hover {
background-color: #e6e6e6;
}
This is the default css style.
.react-calendar {
width: 400px;
max-width: 100%;
background-color: #fff;
color: #222;
border-radius: 8px;
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
font-family: Arial, Helvetica, sans-serif;
line-height: 1.125em;
}
.react-calendar__navigation button {
color: #6f48eb;
min-width: 44px;
background: none;
font-size: 16px;
margin-top: 8px;
}
.react-calendar__navigation button:enabled:hover,
.react-calendar__navigation button:enabled:focus {
background-color: #f8f8fa;
}
.react-calendar__navigation button[disabled] {
background-color: #f0f0f0;
}
abbr[title] {
text-decoration: none;
}
/* .react-calendar__month-view__days__day--weekend {
color: #d10000;
} */
.react-calendar__tile:enabled:hover,
.react-calendar__tile:enabled:focus {
background: #f8f8fa;
color: #6f48eb;
border-radius: 6px;
}
.react-calendar__tile--now {
background: #6f48eb33;
border-radius: 6px;
font-weight: bold;
color: #6f48eb;
}
.react-calendar__tile--now:enabled:hover,
.react-calendar__tile--now:enabled:focus {
background: #6f48eb33;
border-radius: 6px;
font-weight: bold;
color: #6f48eb;
}
.react-calendar__tile--hasActive:enabled:hover,
.react-calendar__tile--hasActive:enabled:focus {
background: #f8f8fa;
}
.react-calendar__tile--active {
background: #6f48eb;
border-radius: 6px;
font-weight: bold;
color: white;
}
.react-calendar__tile--active:enabled:hover,
.react-calendar__tile--active:enabled:focus {
background: #6f48eb;
color: white;
}
.react-calendar--selectRange .react-calendar__tile--hover {
background-color: #f8f8fa;
}
.react-calendar__tile--range {
background: #f8f8fa;
color: #6f48eb;
border-radius: 0;
}
.react-calendar__tile--rangeStart {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
background: #6f48eb;
color: white;
}
.react-calendar__tile--rangeEnd {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
background: #6f48eb;
color: white;
}
This is the custom styling I am trying to add. I can also completely delete all of Calendar.css file and leave it blank but the first picture shown above^^ will still show like that
I don't know if it makes a difference but I am also using tailwind css with this program.
// App.js
import { useState } from "react";
import Calendar from "react-calendar";
import "react-calendar/dist/Calendar.css";
function cal() {
const [date, setDate] = useState(new Date());
return (
<div className="app">
<h1 className="text-center">React Calendar</h1>
<div className="calendar-container">
<Calendar onChange={setDate} value={date} />
</div>
<p className="text-center">
<span className="bold">Selected Date:</span> {date.toDateString()}
</p>
</div>
);
}
export default cal;
This is where I am trying to create the calendar
You can add !important to the properties to force the overwrite, for example:
.react-calendar__tile--rangeEnd {
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
border-top-right-radius: 6px !important;
border-bottom-right-radius: 6px !important;
background: #6f48eb !important;
color: white !important;
}
I'm trying to change the colors of my menu bar, making them black just like it shows up in here with the 3 horizontal black bars at the top right in the figure below. However, I don't know what to look for in my CSS. What field controls it?
Edit: adding my code here to facilitate
/*
* .scss template
*/
nav {
background-color: #f5f5f5;
ul a {
color: $textgray;
img {
height: 64px;
}
}
ul li {
list-style-type: none;
}
i.right {
float: right;
margin-left: -5px;
}
.navlogo img {
height: 64px;
padding: 5px;
}
.navlogo:hover {
background-color: rgba(0, 0, 0, 0.0);
}
}
#toc-sidebar {
#media screen and (min-width: 992px) {
position: absolute;
top: 85px;
right: 23px;
width: 22%;
}
#media screen and (max-width: 992px) {
display: none;
}
&.fix-scroll {
position: fixed;
top: 7px;
}
padding: 3px;
a {
color: #666
}
a:hover {
text-decoration: underline;
font-weight: bold;
}
ul {
li {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
margin-bottom: 0px;
.selected {
font-weight: bold;
}
.H1 {
margin-left: 0px;
}
.H2 {
margin-left: 10px;
}
.H3 {
margin-left: 20px;
}
}
}
.content {
background-color: dark;
padding-bottom: 64px;
margin-bottom: 64px;
ul {
margin-left: 1.2rem;
li {
list-style-type: disc;
}
}
dl {
margin-left:10px;
}
}
.dropdown-content li > a, .dropdown-content li > span {
color: $textgray;
}
h3 {
code {
font-size: 2.5rem;
}
}
#media only screen and (max-width : 600px) {
#index-banner .section {
top: 0;
}
}
.icon-block {
padding: 0 15px;
.material-icons {
font-size: inherit;
}
}
footer.page-footer {
margin: 0;
background-color: #f5f5f5;
}
.row {
a {
color: blue;
}
}
code {
font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal, monospace;
font-size: 13px;
color: #333;
background: #efefef;
border: 1px solid #c7c7c7;
border-radius: 2px;
padding: 0px 1px;
}
pre {
color:#efefef;
background: #333;
padding:8px 15px;
border-radius: 3px;
border:1px solid #c7c7c7;
overflow: auto;
overflow-y: hidden;
code {
color:#efefef;
background: #333;
text-shadow: 0px 1px 0px #000;
margin: 0px;
padding: 0px;
border: none;
}
}
.center-image {
margin: 0 auto;
display: block;
}
table {
line-height: 1.0rem;
}
table.border {
thead {
border-bottom: none;
}
tbody {
border: 1px solid black;
}
}
html {
font-size: 90%;
}
body {
background: #ffffff;
color: $textgray;
line-height: 1.6;
}
.bread {
padding-top: 48px;
margin: 48px;
ul {
margin-left: 1.2rem;
li {
list-style-type: disc;
}
}
dl {
margin-left:10px;
}
}
img.flip {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
}
.transition,.play {
-webkit-transition: .5s;
-moz-transition: .5s;
transition: .5s;
-webkit-transition-timing-function: cubic-bezier(.4,0,.5,1);
-moz-transition-timing-function: cubic-bezier(.4,0,.5,1);
transition-timing-function: cubic-bezier(.4,0,.5,1);
}
.nodec a {
font-weight:normal;
text-decoration:none;
color:#444;
}
.topborder {
border-top-style: solid;
border-color: $textgray;
border-width: 2px;
}
.bottomborder {
border-bottom-style: solid;
border-color: $textgray;
border-width: 2px;
}
.button-collapse {
color: #textgray;
}
.compact td {
padding: 5px;
}
.panel-info {
border: 1px solid black;
.panel-heading {
background-color: $textgray;
color: white;
h3 {
font-size: 2rem;
margin-top: 0px;
}
}
.panel-body {
padding-left: 1em;
.row {
margin-bottom: 5px;
}
ul {
margin-top: 2px;
margin-bottom: 2px;
margin-left: 2rem;
}
}
}
thanks in advance
You can add this to your CSS and append the class of your navbar and alter the below code to make it dark.
<style>
/* Modify the background color */
.navbar-custom {
background-color: dark;
}
/* Modify text color */
.navbar-custom .navbar-text {
color: white;
}
</style>
This is a basic hamburger-menu:
div {
width: 35px;
height: 5px;
background-color: black;
margin: 6px 0;
}
<p>A menu icon:</p>
<div></div>
<div></div>
<div></div>
From: https://www.w3schools.com/howto/howto_css_menu_icon.asp
Just change the background-color to your color
(I'm not sure whether this answers your question - I'm sorry if not)
I am trying to stylize the input type number. In this way: https://ant.design/components/input-number/ (first input). But without using the ant design framework. Where there are inner-spin, outer-spin I am trying add white background, gray lines and change the inner-spin color, outer-spin. Change the background color I can, but I can not spinns any more. I can not see them.
I can use the bootstrap-react framework, but I do not see such a number input
Code here: https://stackblitz.com/edit/react-cojnud
input[type=number] {
line-height: 27px;
box-sizing: border-box;
font-variant: tabular-nums;
line-height: 1.5;
list-style: none;
-webkit-font-feature-settings: 'tnum';
font-feature-settings: 'tnum';
position: relative;
width: 100%;
height: 32px;
padding: 4px 11px;
color: rgba(0,0,0,0.65);
font-size: 14px;
line-height: 32px;
background-image: none;
-webkit-transition: all .3s;
transition: all .3s;
display: inline-block;
width: 90px;
margin: 0;
padding: 0;
border: 1px solid #d9d9d9;
border-radius: 4px;
}
input[type=number].mod::-webkit-inner-spin-button {
width: 30px;
height: 30px;
position: relative;
display: block;
overflow: hidden;
color: rgba(0,0,0,0.45);
font-weight: bold;
line-height: 0;
text-align: center;
-webkit-transition: all .1s linear;
transition: all .1s linear;
background-color: #fff;
}
input[type=number]::-webkit-inner-spin-button:hover {
color: blue;
}
input[type=number]:hover {
border-color: #40a9ff;
border-right-width: 1px !important;
}
input[type="number"].mod::-webkit-inner-spin-button {
-webkit-appearance: none;
background-color: white;
color: black;
}
Hy there,
try to remove -webkit-appearance: none;
And you will see the spinners again!
You won't be able to modify it across browsers. Better to use it following manner:
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
/* display: none; <- Crashes Chrome on hover */
-webkit-appearance: none;
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}
input[type=number] {
-moz-appearance:textfield; /* Firefox */
}
.number-wrapper {
position: relative;
width: 300px;
height: 30px;
}
.number-wrapper input {
width: 100%;
height: 30px;
box-sizing: border-box;
padding-right: 18px;
text-align: right;
}
.number-wrapper .rocker {
position: absolute;
background: #FFF;
border: 1px solid lightblue;
right: 0;
padding: 2px 4px;
color: #ccc;
transition: all ease-in 100ms;
height: 50%;
box-sizing: border-box;
line-height: 12px;
cursor: pointer;
visibility: hidden;
}
.number-wrapper:hover .rocker {
visibility: visible;
transition: all ease-in 300ms;
}
.number-wrapper .rocker.up {
top: 0;
}
.number-wrapper .rocker.down {
bottom: 0;
transform: rotate(180deg);
border-bottom: none;
}
.number-wrapper .rocker:hover,
.number-wrapper .rocker:focus {
box-shadow: 0 0 4px lightblue;
}
.number-wrapper .rocker:active {
transform: scale(0.4);
}
.number-wrapper .rocker.down:active {
transform: rotate(180deg) scale(0.4);
}
<div class="number-wrapper"><span class="rocker up">^</span><span class="rocker down">^</span><input class="mod" type="text" /></div>
Try This
jQuery('<div class="quantity-nav"><div class="quantity-button quantity-up">⮙</div><div class="quantity-button quantity-down">⮛</div></div>').insertAfter('.quantity input');
jQuery('.quantity').each(function() {
var spinner = jQuery(this),
input = spinner.find('input[type="number"]'),
btnUp = spinner.find('.quantity-up'),
btnDown = spinner.find('.quantity-down'),
min = input.attr('min'),
max = input.attr('max');
btnUp.click(function() {
var oldValue = parseFloat(input.val());
if (oldValue >= max) {
var newVal = oldValue;
} else {
var newVal = oldValue + 1;
}
spinner.find("input").val(newVal);
spinner.find("input").trigger("change");
});
btnDown.click(function() {
var oldValue = parseFloat(input.val());
if (oldValue <= min) {
var newVal = oldValue;
} else {
var newVal = oldValue - 1;
}
spinner.find("input").val(newVal);
spinner.find("input").trigger("change");
});
});
.quantity {
position: relative;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button
{
-webkit-appearance: none;
margin: 0;
}
input[type=number]
{
-moz-appearance: textfield;
border-radius: 5%;
}
.quantity input {
width: 45px;
height: 35px;
line-height: 1.65;
float: left;
display: block;
padding: 0;
margin: 0;
padding-left: 20px;
border: 1px solid #eee;
}
.quantity input:focus {
outline: 0;
}
.quantity-nav {
float: left;
position: relative;
height: 40px;
}
.quantity-button {
position: relative;
cursor: pointer;
border-left: 1px solid #eee;
width: 20px;
text-align: center;
color: #333;
font-size: 13px;
font-family: "Trebuchet MS", Helvetica, sans-serif !important;
line-height: 1.7;
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
.quantity-button.quantity-up {
position: absolute;
height: 46%;
top: 0;
margin-top: 0px;
border-bottom: 1px solid #eee;
}
.quantity-button.quantity-down {
position: absolute;
bottom: 4px;
height: 46%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="quantity">
<input type="number" min="1" step="1" value="1">
</div>
See Code Link
nav.page-nav {
background-color: #1d1d1d;
line-height: 6rem;
font-size: 1.7rem;
}
nav.page-nav .container {
display: -ms-flexbox;
}
nav.page-nav a {
display: block;
width: 9rem;
padding: 0 1.8rem;
border-right: 1px dotted #3d3d3d;
text-decoration: none;
text-transform: uppercase;
text-align: center;
color: #c3c3c3;
text-shadow: 0 1px 0 #000;
}
nav.page-nav a:first-child {
border-left-width: 1px;
border-left-color: #3d3d3d;
}
nav.page-nav a:hover {
color: #e4e4e4;
background-color: black;
}
nav.page-nav .active {
color: white;
background: -ms-linear-gradient(#c95656, #8d0606);
background: linear-gradient(#c95656, #8d0606);
}
nav.page-nav .active:hover {
color: #fff;
}
nav.page-nav .active:before {
position: absolute;
top: 6rem;
display: block;
height: 0;
width: 0;
margin-left: -1.9rem;
border-top: 2rem solid #8d0606;
border-right: 6.5rem solid transparent;
content: "";
}
nav.page-nav .active:after {
position: absolute;
display: block;
height: 0;
width: 0;
margin-left: 4.3rem;
border-top: 2rem solid #8d0606;
border-left: 6.5rem solid transparent;
content: "";
}
<nav class="page-nav">
<div class="container">
Home
About
Schedule
Register
</div>
</nav>
I am confused with the display: block in the nav.page-nav a selector. If I change it to display: inline-block nothing change. Why?
I am also confused with the :before and :after. How do they work in the above code? I mean before supposed to be before the element no bellow it. They are shown bellow each active element.
The most common difference between display:block and inline-block is there alignment.
Display:Block by default takes full width and assigned height to there elements. Placement of display:block elements are one after another, whereas to align them in one line i.e. horizontally we need to use float:left, but display:inline-block elements are by default align in inline no need to used float:left.
Pseudo ::before - is used to assign some content or some style properties before the targeted element, but as you have assigned top:6rem to nav.page-nav .active:before so your before element is at bottom of target element.
Pseudo ::after - is used to assign some content or some style properties after the targeted element.
nav.page-nav {
background-color: #1d1d1d;
line-height: 6rem;
font-size: 1.7rem;
}
/* TODO: nav.page-nav .container */
nav.page-nav .container {
display: -ms-flexbox;
}
/* TODO: nav.page-nav a */
nav.page-nav a {
display: block;
width: 9rem;
padding: 0 1.8rem;
border-right: 1px dotted #3d3d3d;
text-decoration: none;
text-transform: uppercase;
text-align: center;
color: #c3c3c3;
text-shadow: 0 1px 0 #000;
position:relative;
}
/* TODO: nav.page-nav a:first-child */
nav.page-nav a:first-child {
border-left-width: 1px;
border-left-color: #3d3d3d;
}
/* TODO: nav.page-nav a:hover */
nav.page-nav a:hover {
color: #e4e4e4;
background-color: black;
}
/* TODO: nav.page-nav .active */
nav.page-nav .active {
color: white;
background: -ms-linear-gradient(#c95656, #8d0606);
background: linear-gradient(#c95656, #8d0606);
}
/* TODO: nav.page-nav .active:hover */
nav.page-nav .active:hover {
color: #fff;
}
/* TODO: nav.page-nav .active:before */
nav.page-nav .active:before {
position: absolute;
top:6rem;
left:0;
display: block;
height: 0;
width: 0;
border-top: 2rem solid #8d0606;
border-right: 6.5rem solid transparent;
content: "";
}
/* TODO: nav.page-nav .active:after */
nav.page-nav .active:after {
position: absolute;
display: block;
height: 0;
width: 0;
border-top: 2rem solid #8d0606;
border-left: 6.5rem solid transparent;
content: "";
bottom:-2rem;
right:0;
}
<nav class="page-nav">
<div class="container">
Home
About
Schedule
Register
</div>
</nav>
Currently I'm wordpressing a site that is using Bootstrap, and the .dropdown-menu is not appearing in IE8 (and, more importantly, IE9).
From my readings I discovered that there is a filter in navbar that causes this issue. Probably is neither the .navbar or the .dropdown class contain the filter. And I'm not even using the class .navbar, just .dropdown & dropdown-menu.
I would love some input on how to fix this. I'm using SCSS:
.header {
height:90px;
.brand {
height: 90px;
width: 246px;
background: url(../images/logo.png) no-repeat center;
display: block;
float: left;
}
nav {
padding-top:36px;
font-family:$tdSemibold;
ul, li {
padding: 0;
margin: 0;
list-style: none;
}
& > ul {
& > li {
display: inline-block;
margin-left:40px;
z-index: 9999;
& > a {
color: white;
text-transform: uppercase;
font-size: 16px;
letter-spacing:1px;
display:block;
height:30px;
& > span.caret {
display: none;
}
&:hover {
color: #85c1eb;
text-shadow: -1px -1px 0 #{darken(#85c1eb, 40%)};
}
}
&.dropdown:hover > .dropdown-menu {
background: #fff;
z-index: 9999;
display: inline-block;
}
}
}
.dropdown-menu {
background: #fff !important;
border-radius: 0;
#include boxShadow(0 0 5px rgba(0,0,0,.15));
&:before {
content: " ";
display: block;
position: absolute;
top: -5px;
left: 5px;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid white;
z-index: 9999;
}
li {
border-bottom: 1px dashed #eee;
background: #fff;
z-index: 9999;
&:last-child {
border-bottom: none;
}
}
a {
padding: 8px 15px;
font-size: 14px;
color: $blue;
&:hover {
color:white;
}
}
}
}
}