Got a simple question. How do I scale this header? Basically on laptop screen, everything looks good but when I make the browser window thinner to replicate
a mobile screen, the header and the drop down button doesn't seem to scale.
I know I need to use a #media tag but unsure how this actually works.
header{
position: absolute;
background-color: #19212C;
top: 0;
width: 100%;
font-size: medium;
padding:1em;
}
.dropbtn {
background-color: rgba(130, 198, 169, 0.9);
color: #fff;
width: 15em;
}
.dropdown {
position: relative;
display: inline-block;
float: right;
padding-bottom: 1em;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #0144AC;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: white;
border: 1px solid black;
padding: 12px 16px;
text-decoration: none;
display: block;
width: 15em;
}
Your question may be simple, and it seems you already know the answer - you lack the implementation for it.
You're starting with the size of a laptop screen suggests that you are starting out "desktop-first". You can then set a media query for a smaller size screen:
#media screen(max-width: 1280px) {
css goes in here
}
This media query says that the CSS between those brackets will only apply for screen width up to 1280px. You will have to put your own variables in there. and then apply the widths and other necessary CSS to style it according to the screen widths you are accommodating.
Be aware that this is just one of many solutions.
Media queries are a very versatile method and it all depends on what your strategy would be. I won't go into all the other related details of this topic, I've tried to keep it to a minimum, but I do suggest you brush up on this topic as it can be a slippery slope.
Related
I created and off canvas navigation which works great in desktop, but on mobile devices when the menu slides open there is white space added to the bottom of the page.
An example can be found here.
Thanks for your help! :)
you can eliminate that white space by simply adding margin: -40px; or something like that to the .fcFooter class.
.fcFooter {
font-family: 'ff-tisa-web-pro',serif;
font-style: italic;
letter-spacing: .1rem;
font-weight: bold;
color: #8a8b8c;
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
/* margin-top: 40px; This line would be replaced by the following */
margin-top: -40px;
border: 1px #ededed;
border-style: solid none none none;
display: block;
}
You can add that css only to mobile devices by a media query like this:
#media only screen and (max-width: 600px) {
.fcFooter {
margin-top: -40px;
}
}
Please let me know if this was useful
The height and width of the canvas must be declared in the height and width attributes, if you want it work correctly
Wrong:
<canvas style="height: x; width: y;">
Correct:
<canvas height="x" width="y">
I have a navbar, which is pretty standard, and I want to make it a bit thinner.
So I tried this:
http://www.bootply.com/9VC5N55nJD
But the buttons remain too big. Click the drop down, and you'll see the issue. Is there a way to make the navbar thinner in one place? Or do you need to add css for the navbar and the buttons and what ever else may crop up?
Also, if I say it must be 30px in height - on a mobile, that might be too narrow, so do I need a media query for the different sizes?
Here is a working fork of your code.
Bootstrap by default uses a padding-top: 15px and padding-bottom: 15px for .navbar-nav > li > a. The following CSS will take care of this:
.navbar-nav > li > a {
padding-top:10px;
padding-bottom:10px;
}
After reducing the screen size (and for mobile devices as you've mentioned) running a media query that resets them and kind of makes the navbar a bit larger will do the trick. The following is a hacky way to do so:
#media (max-width: 768px) {
// enter css for mobile devices here
.topnav {
font-size: 14px;
}
.navbar {
min-height:50px;
max-height: 50px;
}
.navbar-nav > li > a {
padding-top:15px;
padding-bottom:15px;
}
}
Use the below css and let me know.
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar-brand {
float: left;
height: 40px;
line-height: 20px;
padding: 10px 15px;
}
.navbar-toggle {
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
float: right;
margin-bottom: 0;
margin-right: 15px;
margin-top: 6px;
padding: 6px 5px;
position: relative;
}
You need to fix the CSS for the dropdown. Here's the CSS to add to your stylesheet:
ul.navbar-nav, ul.navbar-nav li {
max-height: 40px;
min-height: 40px;
}
Changing bootstraps formatting like the navbar has been difficult. They have so many styles that are set, that it's tough to find which one you need to change. Just add the above style to the css sheet and you should be gravy.
Edit
Also, why not use height: 40px if you're just going to set the min-height and max-height as the same value?
I'm styling a website and have some h3 headers and paragraphs that are wrapped in a div class named "featured-info".
Also i have a footer element that is in the main wrapper in the body.
The paragraphs are put in italic:
.featured-info p {
font-style: italic;
}
and the footer has a border:
footer {
border-top: 1px solid rgb(128, 128, 128);
}
Also the footer text is a h4 uppercased:
footer h4 {
text-transform: uppercase;
}
The main problem is that i have a setting:
#media screen and (min-width: 750px) that makes some navigation buttons inline and resizes some text but...
when the page size is smaller than 750px the footer styling and the italic font dissapears... and i don't understand why. i will provide more info if is needed. thx!
LE: found it. a damn semi-colon. THANK YOU ALL! didn't expect to get so many responses in such a short time.
now i got another problem
under the menu which changes when the resolution is min 750px i have a h1 header that is usually on center
h1 {
font-size: 2.4213em; /*3.3684em*/
line-height: 1.2656em;
margin-top: 0.4219em;
margin-bottom: 0;
color: rgb(172, 140, 71);
text-align: center;
}
the problem is it gets to to the right when the window is from 750px to 950px. I have these settings:
#media screen and (min-width: 750px){
.main-navigation {
min-height: 90px;
border-bottom: 1px solid rgb(36,36,36);
border-top: 1px solid rgb(36,36,36);
/*overflow: hidden; dubiosssss */
}
.main-navigation ul {
max-width: 950px;
margin: 0 auto;
}
.main-navigation li {
float:left;
margin-left: 20px;
width: 20%;
}
.main-navigation a {
background: none;
}
}
/* media query for 750*/
}
#media screen and (min-width: 950px){
.main-navigation ul {
position: relative;
right: -15px;
}
}
any advice would be great, thanks again!
min-width in a #media parameter means that any size from the size you specified and larger will get the styles that you set.
It sounds like you have some of your styles are put in the wrong place. It is usually better to start small and go large in your CSS. This means specify global styles (styles that won't change) first and then work your way up to large viewports.
You are probably overwriting some styles that you would like to keep.
I am very new to coding in html and css and would like to know a way to get around my problem of positioning an image using pixels. The snippet of code looks like:
#contact .map .box_wrapp{
position: absolute;
left: 670px;
margin: 0;
box-shadow: 0 0 7px 0 rgba(26, 26, 26, 0.4);
padding: 33px 0 33px;
background: white;
top: 41%;
border-radius: 25px;
}
When viewing the page on different screens "670px" is a different distance and it ends up overlapping another image on the same page. How can I either position it relative to the other image or possibly position it using something like device pixels? (I started out programming android apps so the concept of device pixels is familiar to me).
You can use media query and define different style for each monitor.
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
This section will apply on monitor up to 300px width, set couple of this according to your supported devices
#media (max-width: 300px) {
{
#contact .map .box_wrapp{
left: 670px;
margin: 0;
box-shadow: 0 0 7px 0 rgba(26, 26, 26, 0.4);
padding: 33px 0 33px;
background: white;
top: 41%;
border-radius: 25px;
}
}
But better way for you is to set width using percentage and not pixels
Try using css #media rule, this is used to define different style rules for different media types/devices.
e.g
#media only screen and (max-width: 670px) {
#contact .map .box_wrapp{ {
//some style
}
}
#media only screen and (min-width: 350px) {
#contact .map .box_wrapp{ {
//some style
}
}
I am trying to create a box that has a 'highlight' down the sides of it, and at the top.
The CSS for the box was pretty simple, however, now that I introduced this 'highlight' to the design, it has added another level of complexity to the CSS...
I have tried a lot of things, not sure if they will help but here is my most recent:
/* Define the Main Navigation Drop Downs */
#mn_navigation .dd {position:relative;width:226px;padding:29px 0 0;background:transparent url("//beta.example.co.uk/_images/_global/dd_handle.png") no-repeat;z-index:1000;}
#mn_navigation .dd nav {padding:30px 0;background:#3E5032 url("//beta.example.co.uk/_images/_global/dd_bg.png");border-radius:3px;}
#mn_navigation .dd nav a {font-family:Arial, Helvetica, sans-serif;font-size:12px;color:#fff !important;height:25px;line-height:25px;}
Please note I have posted the above to show that I have actually tried to sort this myself. The above code will probably not even help as a starting point as a restructure of the HTML may be necessary!
Here is the current HTML (probably needs to be restructured):
<div id="dd_foo" class="dd">
<nav>
LINK
</nav>
</div>
Here is a possible restructure (something like):
<div id="dd_foo" class="dd">
<div class="handle"><!-- Dropdown Handle --></div>
<nav>
LINK
</nav>
</div>
This is what I need the box to look like (notice the faint white border at the top and half way down the sides):
I have also included the box split into its separate elements (handle and background)
I think I can see how this can be done with clever overlaps and nested divs, but ideally I don't really want to resort to this... Can anybody suggest an alternative solution?
Simplest approach
You can try achieving this using a simple box shadow:
.plaque {
box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.32);
/*...*/
}
An Example
Here's an example using 1 class and a div on jsbin.
Copy paste code
This code is only for modern browsers; it might cause ie < 9 and other non supporting browsers to explode.
.plaque:after {
top: -9px;
content: " ";
height: 11px;
width: 30px;
position: absolute;
pointer-events: none;
left: 50%;
margin-left: -15px;
display: block;
background-repeat: no-repeat;
}
.plaque {
width: 250px;
height: 100px;
display: block;
border: 0;
outline: 0;
padding: 12px 16px;
line-height: 1.4;
box-shadow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.32);
border-radius: 5px;
border: 1px solid transparent;
font-family: sans-serif;
color: white;
font-size: 1.2em;
text-overflow: ellipsis;
position: relative;
top: 6px;
}
/* Use whatever background you want */
.plaque { background-color: green; }
.plaque:after { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAALCAYAAACZIGYHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAcJJREFUeNqMUktPU0EU/mZuL6Up1RCjC4oRau4t4FJ84EKID/ZAjI9/6Mo/4MadG5dqJGjBatpyuY+2UNreeXDOBE0MNHGSSWZyzvnOd77zicdbd+EVJKyxGPSHmC4XIYSAMQYCoJhn81wJKSnHWhR8D1oZl69yhamiD8GBSefpywc2XKzjy7fP+PDuk5iUJxnksvvkxX1buxkgThOEt5exvr1qJ+XKy5CfvXpow9oSsn6GdqeF40EPK+GKY/ZfTNa3Vm1AI6TdFAeNfQgp0CKgrJehVg1AGl5gJLTWfxGfv15zI3BBnB5CehJGG5Cw8EjY6tw8KjNXsfv9K96//SguMOERgoU6+ic9NH8eQClNGzDQBMLb4FU1fzdxFB+hev0WNnbu2X802TxnkGQJoriNymwZHrFgAbhdidbOK+YTxR0ojLEc3sHmm0dOI8Gq10n9OI1xGLVcMvuGGYyHOYqlKcfK9wvOF3/i12ZvoFK+gsavPUgGSLsJkm4En4xDTqMi45iUZqZdd34zJY7L8was2enoGMHCEmS3l6LxYx9qrJ2I7FTNelBxPlKuYDgYu9nzUe6cenoygqF/J2o7AmcCDACumSjtgWp8aAAAAABJRU5ErkJggg==); }