I have before element which show's line bottom.
Is this possible to add margin right to this before element that it will one space for example 20 pixels in every screen sizes.
Right now as you can see I'm adding space from right with manipulating width property .In here this space didn't show'n.
Please help.
body {
overflow-x:hidden;
}
.link_more {
margin-left: auto;
text-align: right;
position: relative;
z-index: -1
}
.link_more a {
text-decoration: none;
font-size: 18px;
font-weight: 700;
color: #000;
}
#media only screen and (max-width: 768px) {
.link_more a {
margin-right:0
}
}
.link_more a:before {
content: "";
position: absolute;
border-bottom: 1px solid #000;
width: 9.6%;
top: 25px
}
#media only screen and (max-width: 768px) {
.link_more a:before {
width:16%;
}
}
#media only screen and (max-width: 1200px) {
.link_more a:before {
width:10%
}
}
#media only screen and (max-width: 992px) {
.link_more a:before {
width:9.6%
}
}
#media only screen and (max-width: 568px) {
.link_more a:before {
width:calc(100% - 73.7vw)
}
}
#media only screen and (min-width: 1200px) {
.main_wallpaper .main_content .link_more a:before {
content:"";
position: absolute;
border-bottom: 1px solid #000;
width: 8.6%;
top: 25px
}
}
<div class="link_more">
more
</div>
If you want right margin of 20px, You can use right:20px; instead of width
.link_more a {
text-decoration: none;
font-size: 18px;
font-weight: 700;
color: #000;
right:20px;
position:relative;
}
.link_more a:before {
content: "";
position: absolute;
border-bottom: 1px solid #000;
width: 100%;
top: 25px
right:20px;
}
Related
I'm a novice, so please excuse me.
I am making a site for work, and using bootstrap. I have a login drop down in the navbar. It looks fine on desktop view, but when scaled way down for mobile view, the once you click the login button or drop down it gets jerky and then the navbar gray bar extends down and just looks all screwed up. HELP!
Here's links.
https://web.gettips.com/redesign7/index.html
https://web.gettips.com/redesign7/css/styles.css
Below is the code for the media queries:
#charset "UTF-8";
/* CSS Document */
#media (max-width: 375px) {
.title {
padding-top: 270px;
}
}
#media only screen and (max-width: 400px) {
.title {
padding-top: 0;
font-size: 12px;
}
#toplogin img {
width: 60px;
height: auto !important;
}
}
#media only screen and (max-width: 767px) {
.footer-bs .footer-nav,
.footer-bs .footer-social,
.footer-bs .footer-ns {
border-left: solid 1px rgba(255, 255, 255, 0.10);
}
#toplogin img {
width: 90px;
height: auto !important;
}
}
#media only screen and (max-width: 773px) {
.title {
padding-top: 5px;
font-size: 15px;
}
#toplogin img {
width: 90px;
height: auto !important;
}
}
#media only screen and (max-width: 1029px) {
.title {
padding-top: 5px;
font-size: 20px;
}
#toplogin img {
width: 100px;
height: auto !important;
}
.panel-heading h1 {
font-size: 25px;
}
}
#media (max-width: 1118px) {
.header img {
width: 80px;
height: auto !important;
}
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
padding: 3px;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
/* float: none!important;
*/
margin: 0px -15px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 5px;
padding-bottom: 5px;
}
.navbar-text {
float: none;
margin: 15px 0;
}
/* since 3.1.0 */
.navbar-collapse.collapse.in {
display: block!important;
}
.collapsing {
overflow: hidden!important;
}
.dropdown-menu {
font-size: 16px;
}
}
Its because you are add width 100% after click... Add to the div width 100% before click, so when you click on button, the div already have a correct width. See, I add a custom class and define a width.
This question already has answers here:
Bootstrap 3 Navbar Collapse
(12 answers)
Closed 6 years ago.
Currently when the browser width drops below 768px, the .navbar changes to collapsed mode. I want to change this width to 992px so when the browser is below 992px the .navbar changes to collapsed mode.. I am using bootstrap 3.3.6
I am using this code but it doesn't work for me
#media screen and (max-width: 992px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
}
I was looking for exactly the same thing and I found this , It works 100%!
You need to add this css
#media (max-width: 992px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
}
Also you need this javascript
$('#monitor').html($(window).width());
$(window).resize(function() {
var viewportWidth = $(window).width();
$('#monitor').html(viewportWidth);
});
If it doesn't work, answer me those questions...
Do you use navbar-fixed-top ?
Do you use navbar-inverse?
Take a look at my html code it might help you...
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- This is the main nav menu content -->
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav hover-effect">
<li>Home</li>..........
The recommended approach is to use Bootstrap's 'Customize and download' function to customize Bootstrap to your requirement.
Alternatively you could change your media query, but you might end up overriding a bunch of classes:
#media (min-width: 768px) and (max-width: 992px) {
.collapse {
display: none !important;
}
}
This works, and the navbar collapses at 992px with the css code below:
#media (min-width: 992px) {
.navbar-right .dropdown-menu {
left: auto;
right: 0;
}
.navbar-right .dropdown-menu-left {
left: 0;
right: auto;
}
}
#media (min-width: 992px) {
.navbar-header {
float: left;
}
}
#media (min-width: 992px) {
.navbar-collapse {
width: auto;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-collapse.collapse {
display: block !important;
height: auto !important;
padding-bottom: 0;
overflow: visible !important;
}
.navbar-collapse.in {
overflow-y: visible;
}
.navbar-fixed-top .navbar-collapse,
.navbar-static-top .navbar-collapse,
.navbar-fixed-bottom .navbar-collapse {
padding-left: 0;
padding-right: 0;
}
}
#media (min-width: 992px) {
.container > .navbar-header,
.container-fluid > .navbar-header,
.container > .navbar-collapse,
.container-fluid > .navbar-collapse {
margin-right: 0;
margin-left: 0;
}
}
#media (min-width: 992px) {
.navbar-fixed-top,
.navbar-fixed-bottom {
border-radius: 0;
}
}
#media (min-width: 992px) {
.navbar-fixed-top,
.navbar-fixed-bottom {
border-radius: 0;
}
}
#media (min-width: 992px) {
.navbar > .container .navbar-brand,
.navbar > .container-fluid .navbar-brand {
margin-left: -15px;
}
}
#media (min-width: 992px) {
.navbar-toggle {
display: none;
}
}
#media (min-width: 992px) {
.navbar-nav {
float: left;
margin: 0;
}
.navbar-nav > li {
float: left;
}
.navbar-nav > li > a {
padding-top: 15px;
padding-bottom: 15px;
}
}
#media (min-width: 992px) {
.navbar-form {
width: auto;
border: 0;
margin-left: 0;
margin-right: 0;
padding-top: 0;
padding-bottom: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
}
#media (min-width: 992px) {
.navbar-text {
float: left;
margin-left: 15px;
margin-right: 15px;
}
}
#media (min-width: 992px) {
.navbar-left {
float: left !important;
}
.navbar-right {
float: right !important;
margin-right: -15px;
}
.navbar-right ~ .navbar-right {
margin-right: 0;
}
}
I have tried the following code with bootstrap 3.3.6 and it works.
#media (max-width: 996px) {
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin: 7.5px -15px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
}
Please check this jsfiddle
I sometimes want to recode responsive navigations to be mobile-first instead of having styles that adjust to smaller user devices.
Manually recoding CSS to reverse the style cascade from max-width to min-width isn't as quick as I was hoping.
Sample of CSS that could be recoded to be mobile-first: http://codepen.io/bl4ckdu5t/pen/vOBRqL
nav {
height: 40px;
width: 100%;
background: #455868;
font-size: 11pt;
font-family: 'PT Sans', Arial, sans-serif;
font-weight: bold;
position: relative;
border-bottom: 2px solid #283744;
}
nav ul {
padding: 0;
margin: 0 auto;
width: 600px;
height: 40px;
}
nav li {
display: inline;
float: left;
}
nav a {
color: #fff;
display: inline-block;
width: 100px;
text-align: center;
text-decoration: none;
line-height: 40px;
text-shadow: 1px 1px 0px #283744;
}
nav li a {
border-right: 1px solid #576979;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
nav li:last-child a {
border-right: 0;
}
nav a:hover, nav a:active {
background-color: #8c99a4;
}
nav a#pull {
display: none;
}
/*Styles for screen 600px and lower*/
#media screen and (max-width: 600px) {
nav {
height: auto;
}
nav ul {
width: 100%;
display: block;
height: auto;
}
nav li {
width: 50%;
float: left;
position: relative;
}
nav li a {
border-bottom: 1px solid #576979;
border-right: 1px solid #576979;
}
nav a {
text-align: left;
width: 100%;
text-indent: 25px;
}
}
/*Styles for screen 480px and lower*/
#media only screen and (max-width : 480px) {
nav {
border-bottom: 0;
}
nav ul {
display: none;
height: auto;
}
nav a#pull {
display: block;
background-color: #283744;
width: 100%;
position: relative;
}
nav a#pull:after {
content:"";
background: url('http://s30.postimg.org/68factszx/nav_icon.png') no-repeat;
width: 30px;
height: 30px;
display: inline-block;
position: absolute;
right: 15px;
top: 10px;
}
}
/*Smartphone*/
#media only screen and (max-width : 320px) {
nav li {
display: block;
float: none;
width: 100%;
}
nav li a {
border-bottom: 1px solid #576979;
}
}
I don't know any tool that can help you with that. Here's a good article that can help you to do the changes manually:
link
max-width is the maximum width at which these styles will be shown. A screen wider than the specified number will not use the styles associated with that rule.
Similarly, min-width is the minimum width at which these styles will be shown. A screen narrower than the specified number will not use the styles associated with that rule.
I have a logo that is plain text, and have set up 3 media query to respond to different screen-sizes. In firefox the media queries work correctly, but in safari the last #media (max-width: 680px), has no effect on the font size.
#media (max-width: 1000px) {
header {
padding: 0;
}
.logo {
z-index: 0;
position: relative;
padding: 0 20px;
margin: 20px auto;
height:40px;
margin-top:40px;
}
.logo p {
text-align: center;
text-indent: -110px;
}
.logo p a {
font-size:140px;
font-family: "MaiolaBasic-BoldItalic", Georgia, serif;
color: #000000;
}
#media (max-width: 680px) {
header {
padding: 0;
}
.logo {
z-index: 0;
position: static;
padding: 0 20px;
margin: 20px auto;
height:0px;
margin-top:40px;
}
.logo p {
text-align: left;
text-indent: 0px;
}
.logo p a {
font-size:80px;
font-family: "MaiolaBasic-BoldItalic", Georgia, serif;
color: #000000;
}
Thanks!
I think you just forgot to close some brackets! I always do this with media queries because they color code strangely in my code editor.
Add a closing squiggly bracket before the 2nd #media and also at the end of your code.
Here's it done for you
#media (max-width: 1000px) {
header {
padding: 0;
}
.logo {
z-index: 0;
position: relative;
padding: 0 20px;
margin: 20px auto;
height:40px;
margin-top:40px;
}
.logo p {
text-align: center;
text-indent: -110px;
}
.logo p a {
font-size:140px;
font-family: "MaiolaBasic-BoldItalic", Georgia, serif;
color: #000000;
}} /*Added bracket*/
#media (max-width: 680px) {
header {
padding: 0;
}
.logo {
z-index: 0;
position: static;
padding: 0 20px;
margin: 20px auto;
height:0px;
margin-top:40px;
}
.logo p {
text-align: left;
text-indent: 0px;
}
.logo p a {
font-size:80px;
font-family: "MaiolaBasic-BoldItalic", Georgia, serif;
color: #000000;
}} /*Added Bracket*/
I'm trying to modify just a few classes in my CSS for different screen resolutions, I'm aiming to have:
The default applied CSS for 1200+ width,
A media query embedded in the css for resolutions between 601 and
1199 px, //This is what's not working
A media query embedded in the css for resolutions 600px and below
When i use a single width condition, for example #media screen and (max-width: 600px) { , the css is applied as it should be.
However when I try #media screen and (max-width: 1199 px) and (min-width: 601){ the style never gets applied..
I've tried swapping the order of these conditions and also just having #media screen and (max-width: 1199 px) on the basis that the 600px rule will override it afterward but for some reason it just doesn't seem to work. Just to be clear, i've either got the default styling or the 'max-width: 600px' style when i shrink the screen to less than 600px, i can't seem to get a style applying for the middleground.
Any obvious mistakes in my CSS?/suggestions? Would be appreciated!
I bunged my html and css into a jsfiddle for anyone who wants to see for themselves http://jsfiddle.net/X6cZ7/3/ (Observe the navigation bar li items as you drag the view for the website, they change style at <600px but should also look red (for testing) at <1199 yet they dont) Only testing on Chrome at the mo, in case that's relevant.
CSS (Relevant #media stuff at the bottom..):
* {margin: 0; padding:0;}
body
{
font: normal 100% 'Poiret One', 'Trebuchet MS', sans-serif;
color: Grey;
background-image: url('Images/background_gradient.png');
background-repeat:repeat-x;
background-color: #d4ffaa;
margin: 0 auto;
height: auto;
max-width: 90%;
}
h2
{
margin: 0.6em 0;
color: Grey;
border-bottom: 2px solid #d4ffaa;
font: normal 2em 'Poiret One', 'Trebuchet MS', sans-serif;
}
#central_container
{
width: 100%;
margin: 0 auto;
height: 100%;
float: left;
}
#leftside_container
{
float: left;
width: 67.1%;
clear: left;
}
#header_container
{
width: 100%;
max-height: 300px;
height: 15em;
}
#header_title
{
width: 100%;
height: 80%;
}
#header_title h1{ font-size: 4em; color: Ivory;}
#navbar_container
{
width: 100%;
height: 20%;
}
.navbar_links ul{ list-style-type: none; }
.navbar_links li
{
display: inline;
size: 4em;
}
.navbar_links a:link, a:visited
{
font-size: 1.5em;
text-align: center;
text-decoration:none;
padding: 0.1em 0.4em;
color: Ivory;
border-left:10px solid transparent;
border-right:10px solid transparent;
border-bottom: 10px solid Ivory;
}
.navbar_links a:hover, a:active
{
color: Grey;
border-bottom: 10px solid #d4ffaa;
}
#currentpage_container
{
background-color: Ivory;
width: 100%;
height: 20%;
}
#currentpage_content
{
font-family: 'Trebuchet Ms';
padding: 1em 3em;
}
#currentpage_content p { padding: 0.8em;}
#rightside_container
{
float: right;
width: 33%;
}
#register_container
{
width: 100%;
max-height: 300px;
height: 15em;
}
.bubble{
background-color: Ivory;
border-radius: 15px;
-moz-border-radius: 15px;
display: inline-block;
position: relative;
height: 80%;
width: 100%;
margin: 1em 0;
}
.bubble p
{
padding: 1em;
white-space: preline;
font-weight: bold;
}
.bubble::after { /*arrow*/
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-right: 30px solid Ivory;
content: '';
position: absolute;
left: -30px;
top: 50%;
}
#contact_container
{
background-color: Ivory;
width: 100%;
}
#contacts_content{ padding: 1em 3em; }
#contacts_content .text
{
font: normal 0.9em 'Trebuchet Ms';
padding: 0.8em 0;
}
.contactNum, .contactEmail { font-size:1.5em; }
.contactNum::before { content:url(Images/phone_icon.gif);}
.contactEmail::before { content:url(Images/email_icon.gif);}
#logos_content
{
padding: 0.5em 3em;
height: 150px;
}
.logo
{
display: none;
max-width: 40%;
position:relative;
max-height: 40%;
}
.logo2
{
display: none;
max-width: 40%;
position:relative;
max-height: 40%;
right: -50%;
}
#social_content
{
padding: 1em 3em;
}
/* SMALLER RESOLUTION CHANGES */
#media screen and (max-width: 1199 px) and (min-width: 601){
.navbar_links ul{ list-style-type: none; }
.navbar_links li
{
display: inline;
background: Ivory;
}
.navbar_links a:link, a:visited
{
font-size: 1.5em;
padding: 0.1em 0.4em;
color: red;
border-left:3px solid transparent;
border-right:3px solid transparent;
border-bottom: 3px solid #d4ffaa;
}
.navbar_links a:hover, a:active
{
color: Grey;
border-bottom: 3px solid Grey;
}
}
#media screen and (max-width: 600px) {
#central_container,
#leftside_container,
#rightside_container,
#header_container,
#header_title,
#navbar_container,
#currentpage_container
{
float: none;
width: auto;
height: auto;
}
#header_title h1{ font-size: 3em; color: Ivory;}
.navbar_links ul{ list-style-type: none; margin-bottom:1em;}
.navbar_links li
{
display: inline;
}
.navbar_links a:link, a:visited
{
padding: 0;
border-left: 2px solid transparent;
border-right: 2px solid transparent;
border-bottom: 2px solid Ivory;
}
.navbar_links a:hover, a:active
{
border-bottom: 2px solid #d4ffaa;
}
}
In your css there is some typing mistake, hence its not working, please check below
Not Correct
#media screen and (max-width: 1199 px) and (min-width: 601){
}
Correct one
#media screen and (min-width: 601px) and (max-width: 1199px){
}
EDIT:
There shouldn't be any spaces between the value and unit, i.e. 1199 px is wrong it should be 1199px.
Yo have forgot to put "px" in max-width: 1199. I think this is creating problem.
Anyways, You should code for mobile first & keep on coding for larger resolutions.
Your fiddle: http://jsfiddle.net/X6cZ7/4/