I have a web page with a navbar and map div. Everything is great but there is a scroll bar on the page and you must scroll to see the full map. I would like the full map div to show up on the screen without any scrolling. How do I accomplish this? Thank you
HTML:
<nav class="default" role="navigation">
<div class="nav-wrapper">
NTN Trails
<a href="#" data-activates="mobile-demo" class="button-collapse show-
on-large"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
</ul>
<ul class="side-nav" id="mobile-demo">
<li>Login</li>
<li>Sign up</li>
</ul>
</div>
</nav>
<script>
$('.button-collapse').sideNav({
menuWidth: 240, // Default is 240
edge: 'left', // Choose the horizontal origin
closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor
}
);
</script>
<!--put your initial page content here-->
<div id="map"></div>
CSS:
html, body, #map {
height: 100%;
width: 100%;
}
#media only screen and (min-width: 993px){
nav a.button-collapse {
display: block;
}
}
Related
I made a hamburger menu, and when I click on the links it closes it. Also has a logo which disappears when I click on the hamburger button.
The webpage has a mobile and a desktop computer version that doesn't have a hamburger menu.
But I have a problem. On the Desktop version, if I click on the links the Logo disappears as well.
I know that it does it because the hamburger-close-after-click event triggers it.
But I don't know how I could change it to make it work well.
jQuery Code
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
const links = document.querySelectorAll('.nav-links li');
var mylogo = document.getElementById("myLogo");
hamburger.addEventListener('click', () => {
navLinks.classList.toggle('open');
links.forEach(link =>{
link.classList.toggle("fade");
});
});
//logo-toggle
$(document).ready(function(){
$('.hamburger').click(function() {
$('.logo-container').toggle().delay( 800 );
});
});
// hamburger-close-after-click event
$( '.nav-links li a' ).on("click", function(){
$('#hamburgerID').click();
});
HTML Code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<nav>
<div class="hamburger" id="hamburgerID">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
</nav>
<header class="header" id="myHeader">
<div class="logo-container" id="myLogo">
<img src="./img/logo.png" alt="logo"/>
</div>
<nav>
<ul class="nav-links">
<li><a class="nav-link" href="#details">DETAILS</a></li>
<li><a class="nav-link" href="#description">DESCRIPTION</a></li>
<li><a class="nav-link" href="#aboutus">ABOUT US</a></li>
</ul>
</nav>
The problem with pictures
[
You can use JQuery.toggleClass() to add and remove CSS classes, instead of using JQuery.toggle(), e.g.:
$('.hamburger').click(function() {
$('.logo-container').toggleClass('open');
})
And then, in the CSS file, define the visibility depending on the screen size, e.g.:
.logo-container { display: 'none' }
.logo-container.open { display: 'block' }
#media (min-width: 1025px) {
.logo-container { display: 'block' }
}
(Note: You will want to decide yourself how to identify the appropriate size to hide and show the elements. See also e.g.: how-to-target-desktop-tablet-and-mobile)
I tried to hide a div with my sidebar with this method:
/* For mobile phones: */
#media (max-width: 576px) {
.sidebar {
display: none!important;
}
}
/* For tablets */
#media (max-width: 768px) {
.sidebar {
display: none!important;
}
}
The sidebar listens to these rules but it seems like the content is disappearing but the <div> is actually staying. It might be like this because <div> with the sidebar is actually a component. But then I don't know how to solve it.
My page:
<template>
<div>
<sidebar />
<main-content/>
</div>
</template>
The sidebar component:
<template>
<div class="sidebar">
<div class="sidebar-header">
<div class="logo"><img src="../../../components/img/logo.svg"/></div>
System
</div>
<ul class="sidebar-nav">
<!--<li>Home</li>-->
<!--<li>Popular</li>-->
<!--<li>News and events</li>-->
<!--<li>Pages</li>-->
<li class="nav-item">
<img class="nav-icon" src="../../../components/img/users.svg" />Users
<ul>
<li class="nav-item">Import</li>
<li class="nav-item">Invitation</li>
</ul>
</li>
<!--<li>Organisation</li>-->
<li class="nav-item">
<img class="nav-icon" src="../../../components/img/polls.svg" />Poll
</li>
</ul>
</div>
</template>
Most probably your component styles are scoped. See the documentation how it works.
A posible solution is to move the style block to the component itself:
<template>
<div class="sidebar">
<div class="sidebar-header">
<div class="logo"><img src="../../../components/img/logo.svg"/></div>
System
</div>
<ul class="sidebar-nav">
<li class="nav-item">
<img class="nav-icon" src="../../../components/img/users.svg" />Users
<ul>
<li class="nav-item">Import</li>
<li class="nav-item">Invitation</li>
</ul>
</li>
<li class="nav-item">
<img class="nav-icon" src="../../../components/img/polls.svg" />Poll
</li>
</ul>
</div>
</template>
<style scoped>
/* For mobile phones: */
#media (max-width: 576px) {
.sidebar {
display: none !important;
}
}
/* For tablets */
#media (max-width: 768px) {
.sidebar {
display: none !important;
}
}
</stlyle>
Another solution is to declare a non scoped style block, this usually goes in your App.vue file.
The problem was in CSS for a container with main content. It had left margin, so when the sidebar disappeared, it stayed at the same place, not taking the width of the removed sidebar.
Trying to use bootstrap to design a top navigation layout and I see that it defaults to left align. how do I get it to use full width of top?
Current
https://jsfiddle.net/v2notb5n/
<nav class="navbar">
<div class="fluid-container">
<ul class="nav navbar-nav navbar-inverse">
<li class="nav_page active"> Home </li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#" class="nav_txt"> Team <span class="caret"></span></a></li>
<ul class="dropdown-menu">
<li>National</li>
<li>Geo</li>
<li>Team Pictures</li>
</ul>
<li> About us </li>
</ul>
</div>
</nav>
Expected result:
https://imgur.com/a/ZQDR0
I tried something similar I found here Bootstrap navbar justify / span menu items occupying full width
but that didn't work for me.
Updated based on suggestions and answer here: https://jsfiddle.net/uahwra75/1/
To have the navbar stretch the full width, simply overwrite the float: left on .navbar-nav for medium screen widths and higher, with:
#media screen and (min-width: 768px) {
.navbar-nav {
float: none;
}
}
I've created a working fiddle showcasing this here.
Also note that you have incorrectly used the class fluid-container instead of container-fluid, which will affect your padding. I've corrected that in the fiddle abopve, and the snippet below:
#media screen and (min-width: 768px) {
.navbar-nav {
float: none !important; /* StackSnippets require more specificity */
}
.navbar-nav li {
width: calc(100% / 3);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar">
<div class="container-fluid">
<ul class="nav navbar-nav navbar-inverse">
<li class="nav_page active">
Home
</li>
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>National</li>
<li>Geo</li>
<li>Team Pictures</li>
</ul>
</li>
<li>About us</li>
</ul>
</div>
</nav>
EDIT
To additionally ensure that the titles are centralised, you're looking to add a width to .navbar-nav li that is 100% divided by the number of columns. COnsidering you have three columns, you divide by three:
.navbar-nav li {
width: calc(100% / 3);
}
Note that like the removal of the float, this should go inside of the media query.
I've created a new fiddle showcasing this here.
Hope this helps! :)
Currently got the following setup by checking out other previously asked questions, although now I'm stuck as it won't span out
you mean you want it to extend to full screen width? if so you need to make its parent element width 100% too for example
body {
width: 100%;
}
it could be another parent like a div.container or whatever..
for 100% width of span
<style type="text/css">
.banner span{
width: 100% !important;
}
</style>
You can add img inside as this.
<div ng-controller="MainCtrl">
<header class="banner">
<div class="banner-wrapper">
<div class="banner-title">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/8/81/Williams_Companies_logo.svg/1280px-Williams_Companies_logo.svg.png" height="100px" width="100%">
</div>
<nav class="banner-nav">
{{ portal | welcome_navigation }}
</nav>
</div>
<nav class="nav-menu" id="header-tabs">
<ul>
<li class="nav-menu-title">Back to Main Site</li>
<li class="nav-contact">| Questions? Get in touch: <li class="nav-number">12345568693</li>
</ul>
</nav>
</header>
</div>
This actually has nothing to do with the width, as header elements are already supposed to span the whole width. There must be some default margin or padding in your html body. All you need to do is set default margin and padding on body tag to be 0.
(I usually follow setting margin/padding on body to 0 as a general practice)
You can remove your existing css code and replace it with this (I checked, it's working):
body {
padding: 0;
margin: 0;
}
<header class="banner">
<div class="banner-wrapper">
<div class="banner-title">
{{ portal | logo }}
</div>
<nav class="banner-nav">
{{ portal | welcome_navigation }}
</nav>
</div>
<nav class="nav-menu" id="header-tabs">
<ul>
<li class="nav-menu-title">Back to Main Site</li>
<li class="nav-contact">| Questions? Get in touch:
<li class="nav-number">12345568693</li>
</ul>
</nav>
</header>
I am looking to make a layout page, which has a banner at the top, that handles the following:
Desktop - Maximized screen (Would have a center page used of 1024px limited)
Desktop - as soon as the size goes lower than 1024, the banner scaled down, to fit the width of the screen
Phone/Mobile - Banner uses full width
Below is a technically rendered diagram, using software which is beyond any of your imaginations, so I will not elaborate, but hopefully it get's the point across.
First box shows a screen with the browser maximized. Banner goes to 1024 max, as does the content of the screen below it.
Next image shoes a 1024 resolution screen. Screen uses full browser.
Last image down shows a screen, with the browser NOT maximized, and using less than 1024 pix. The banner resizes down (doesn't crop... resizes)
And the bottom right is a phone. No brand... just a phone. :)
Can you show how this can done? Can the image (an ?) be resized based on these requirements?
My attempt at the moment:
<div class="container">
<div id="myCarousel" class="carousel">
<div class="carousel-inner">
<img class="item active img-responsive fullsize" src="/Content/images/1.jpg" />
<img class="item img-responsive fullsize" src="/Content/images/2.jpg" />
<img class="item img-responsive fullsize" src="/Content/images/3.jpg" />
</div>
</div>
<ul class="nav nav-pills navbar-inverse">
<li class="active"><span class="glyphicon glyphicon-home"></span> Home</li>
<li><span class="glyphicon glyphicon-list"></span> Our Friesians</li>
<li><span class="glyphicon glyphicon-picture"></span> Stock</li>
<li class="dropdown">
<span class="glyphicon glyphicon-info-sign"></span> Help <b class="caret"></b>
<ul class="dropdown-menu">
<li><span class="glyphicon glyphicon-info-sign"></span> About Us</li>
<li class="divider"></li>
<li class="dropdown-header">Contact Details</li>
<li><span class="glyphicon glyphicon-inbox"></span> Contact Us</li>
<li><span class="glyphicon glyphicon-map-marker"></span> Directions</li>
</ul>
</li>
</ul>
<div class="container-fluid">
This is the Index page.
</div>
</div>
This is the simplest possible way to do it. You can just make the image max-width: 1200px, but that could be a problem down the line. I'm pretty sure this has been asked, and answered already. I'm too lazy to find it.
<html>
<head>
<style>
#mlp{
/*The next line controls the fit of the image.*/
max-width: 100%;
}
#container{
/*The next line controls the max of the container.
Change it to the value you want.*/
max-width: 1000px;
border: 1px solid black;
}
/*media query suggested as an alternative to the above.*/
#media(max-width: 480px) {
#mlp {
max-width: 100%;
}
#container {
max-width: 480px;
}
}
</style>
</head>
<body>
<div id="container">
<img id="mlp" src="http://img64.imageshack.us/img64/4163/01an1.jpg">
</div>
</body>
</html>
There are css media queries that would switch out the image with hiding instead, but it's more code. Media queries should be placed at the bottom to take precedence when they're needed.