I am trying to make a responsive sticky navigation bar which will shorten when the screen gets too small (for mobile). The navigation bar works fine without the hamburger bars on my laptop, but i am struggling to implement the following code on W3C with my code.
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_topnav
the following is a link to jsfiddle with the HTML, CSS and Javascript code I am using.
HTML
https://jsfiddle.net/cpeotvsf/25/
below is my code
<body>
<div class="top-container">
<h1>testing header</h1>
<h3>Scroll down to see learn more.</h3>
</div>
<div class="header" id="myHeader">
<div class="navbar" id="Mynavbar">
Home
<div class="dropdown">
<button class="dropbtn">Services
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
Red or Black Tarmac Drives and Paths
Fencing and Gates
Shingle and Coloured Gravels
Drainage Work
Patios and Crazy Paving
Block Paved Driveways and Paths
Turfing and Artificial Grass
Brick and Purbeck Stone Walls
Decking and Rockeries
</div>
</div>
Gallary
Before and After
Testimonials
Contact Us
<a href="javascript:void(0);" class="icon" onclick="myFunctionn()">
<i class="fa fa-bars"></i>
</a>
</div>
</div>
The CSS and Javascript I am using are in the jsfiddle link above
Any help on this would be greatly appreciated
Your js is fine but jsFiddle keeps the script's load-type on load rather than at the bottom of the page so the onClick can't find the following function:
function myFunctionn() {
// place this script below your body content.
}
To make the above function run properly in jsFiddle, just click JavaScript + No-Library (pure JS) ▼ and change the load type to bottom of body then re-run the script.
jsFiddle with load type updated: https://jsfiddle.net/cpeotvsf/35/
Related
Hy, i'm trying to build an Electron app that uses Semantic UI. At the moment, i'm trying to implement a tabular menu as shown in the basic tab example, and this is the behavior i'm trying to implement: https://semantic-ui.com/modules/tab.html#basic-tabs.
My code seems to be all right but the menu isn't behaving as expected. In the image below you can see that the content of the div's just appears down the others, as a normal div html section.
Well, in my research i found that we have to put somethiing like
<script>
var $ = require('jquery');
$('.item').click(function(){
$('.active').removeClass('active');
$(this).addClass('active');
});
</script>
And i did, just don't know if the right way. After that the functionality of changing the pressed button is working, i.e. if i press the "second" button the ui render correctly, lik image below. And so on with the other possible tabs.
I've already did the following steps:
-> Import jQuery via NPM with npm install jquery --save and this gave me "jquery": "^3.5.1" on my package.json file.
My full code is below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./Semantic-UI-CSS-master/semantic.css">
</head>
<body>
<div class="ui visible left demo vertical inverted thin sidebar labeled icon menu">
<a class="item" href="index.html">
<i class="tint icon"></i>
Análise
</a>
<a class="item" href="resultados.html" style="color: aquamarine;">
<i class="chart bar icon" style="color: aquamarine;"></i>
Gráficos
</a>
</div>
<div class="pusher">
<div class="ui basic segment">
<div style="width: 80%; margin: 2%;">
<div class="ui top attached tabular menu">
<a class="item active" data-tab="hidrogenio">
Níveis de hidrogenio
</a>
<a class="item" data-tab="etano">
Photos
</a>
<a class="item" data-tab="etileno">
Etileno
</a>
</div>
<div class="ui bottom attached segment" data-tab="hidrogenio">
<p>First Tab</p>
</div>
<div class="ui bottom attached segment" data-tab="etano">
<p>Second Tab</p>
</div>
<div class="ui bottom attached segment" data-tab="etileno">
<p>Third Tab</p>
</div>
</div>
</div>
</div>
<script>require('./js/renderer')</script>
</body>
<script>
var $ = require('jquery');
$('.item').click(function(){
$('.active').removeClass('active');
$(this).addClass('active');
});
</script>
</html>
I don't know why the div with the data-tab aren't working as expected and remain "hidden" until we press the respective button...
I'd appreciate so much the help! Thanks.
after looking on your code and checking the documentation which I post below the basics:
<!-- The basic format for a tabular menu -->
<div class="ui top attached tabular menu">
<a class="active item" data-tab="first">First</a>
<a class="item" data-tab="second">Second</a>
<a class="item" data-tab="third">Third</a>
</div>
<div class="ui bottom attached active tab segment" data-tab="first">
First
</div>
<div class="ui bottom attached tab segment" data-tab="second">
Second
</div>
<div class="ui bottom attached tab segment" data-tab="third">
Third
</div>
and the JS code:
// the require js code to make semantic read that html as a tabular menu
$('.menu .item')
.tab()
;
I don't see the required JS part on your code, just the actions your script will run when you click an item. You really need the JS code part I posted in order for that to work.
I am creating a website and would like to use this ready made slider on my page. I have added it to my code, however, the left button does not work. The right button works but the hover disappears on mobile view.
I am new to web development and therefore still learning. If someone could help that would be much appreciated. The CodePen for this slider is https://codepen.io/bryan-erwin/pen/dJEYVr
<header>
<div class="container" id="container">
<div class="caption" id="slider-caption">
<div class="caption-heading">
<h1>Example</h1>
</div>
<div class="caption-subhead"><span></span></div><a class="btn"
href="#"></a>
</div>
<div class="left-col" id="left-col">
<div id="left-slider"></div>
</div>
<ul class="nav">
<li class="slide-up">
<a id="up_botton" href="#"><</a>
</li>
<li class="slide-down">
<a id="down_button" href="#">></a>
</li>
</ul>
</div>
</header>
I would like the left button to go to the previous slide and the right button hover to work on all views
Your javascript code is incomplete you are listening to the right side button click event by this code:
let down_button = document.getElementById('down_button');
down_button.addEventListener('click',function(e){
e.preventDefault();
clearInterval(autoplay);
nextSlide();
autoplay;
});
you have to add code for the left side button also like this:
let up_button = document.getElementById('up_button');
up_button.addEventListener('click',function(e){
e.preventDefault();
clearInterval(autoplay);
prevSlide(); // you have to create this function
autoplay;
});
for this, you have to also add an id="up_button" to the left side button.
I'm almost finished with my Full Stack Nanodegree final project and while I'm waiting for help on my instructor, I've decided to build my portfolio. However, I'm trying to add a next & previous button inside my jumbotron. It's not working. When I try to add those two buttons, it appears next to my placeholder image instead of the left and right of my container. How can I fix this? More specifically, I'm wondering where to place this snippet of code:
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
If you're interested in helping me, here's my GitHub repo: https://github.com/10asmock/portfolio.
I'm also using W3schools' guide on creating a JS slideshow as a reference: https://www.w3schools.com/howto/howto_js_slideshow.asp
Float an element right or left by utilizing Bootstrap 4's float-right and float-left classes.
<div class="float-left">
<!-- left -->
</div>
<div class="float-right">
<!-- right -->
</div>```
More information can be found in the Bootstrap v4 docs
I am very new to HTML/CSS/JS and I have started implementing Semantic UI. I'm struggling with the documentation as it seem more geared towards a more experienced user.
I'm trying to create a single page application that has two sidebar menus, one on the left and one on the right. I'd like the right one to be hidden by default and visible when a button is clicked. I'd like it appear over top of the content and not push it to the left. I'd like the right hand menu to be out by default, but be collapsible with a button press. The following is as far as I've gotten, which is close but the right menu still pushes the content left with the right menu out. There is also a overlay, which is called a Dim. I'm guessing that I have to write the JS desperately and call it using the onClick, which would then allow me to further define the setting for the menu, but I'm not sure how best to do this. Any help would be greatly appreciated as I've been at this for many
hours now.
This a good example of what I am attempting to achieve: http://egemem.com/theme/kode/v1.1/blank.html
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="semantic/out/semantic.min.js"></script>
<!-- RIGHT MENU -->
<div class="ui left sidebar menu inverted vertical">
<a class="item">1</a>
<a class="item">2</a>
<a class="item">3</a>
</div>
<!-- RIGHT MENU -->
<div class="ui right sidebar menu inverted vertical dimm">
<a class="item">1</a>
<a class="item">2</a>
<a class="item">3</a>
</div>
<div class="pusher">
<!-- BODY -->
<button id="sidebar_left_toggle" onclick="$('.ui.left.sidebar').sidebar('toggle');">
show sidebar
</button>
<button id="sidebar_right_toggle" onclick="$('.ui.right.sidebar').sidebar('setting', 'transition', 'overlay').sidebar('toggle');">
show sidebar
</button>
</div>
I solved this myself after finally finding an answer to another question. Here is what I determined in case it helps a fellow beginner out.
<!-- LEFT MENU -->
<div class="ui left vertical inverted sidebar menu visible">
<a class="item">1</a>
<a class="item">2</a>
<a class="item">3</a>
</div>
<!-- RIGHT MENU -->
<div class="ui right vertical inverted sidebar menu">
<a class="item">1</a>
<a class="item">2</a>
<a class="item">3</a>
</div>
<div class="pusher">
<div class="ui container">
<!-- BODY -->
<button id="left-sidebar-toggle">
show sidebar
</button>
<button id="right-sidebar-toggle">
show sidebar
</button>
</div>
</div>
<script>
$('.ui.left.sidebar').sidebar({
dimPage: false,
transition: 'push',
exclusive: false,
closable: false
});
$('.ui.left.sidebar')
.sidebar('attach events', '#left-sidebar-toggle');
$('.ui.right.sidebar').sidebar({
dimPage: false,
transition: 'overlay',
exclusive: false,
closable: false
});
$('.ui.right.sidebar')
.sidebar('attach events', '#right-sidebar-toggle');
</script>
In my web application using jQuery and jQuery UI (1.10.2 and 1.10.4 respectively), I use the CSS in jQuery CSS in /js/jquery-ui-1.10.4/css/ui-lightness/jquery-ui-1.10.4.min.css of the zip file from the jQuery site. I had a topNav bar like so before I got the jQuery-based autocomplete function to work:
MyProfile Link1 Link2 | search box | Logout
My search box is 300px and my fonts are 12px, and the width of the div container above is 700px and BEFORE I added jQuery autocomplete support, it was something like this:
<div class="topNav">
<div class="left">
<a href...>MyProfile</a>>  
<a href...>Link1</a>>  
<a href...>Link2</a>>  
</div>
<input id="searchBox" name="searchBox" type="search" >
<div class="right">
<a href...>Logout</a>
</div>
</div>
It was all well aligned then (all of topNav in one line).
Now, after adding jQuery support like so:
<div class="topNav">
<div class="left">
<a href...>MyProfile</a>>  
<a href...>Link1</a>>  
<a href...>Link2</a>>  
</div>
<!-- div-ing the input searchBox was the only change: -->
<div class="ui-widget">
<input id="searchBox" name="searchBox" type="search" >
</div>
<div class="right">
<a href...>Logout</a>
</div>
</div>
And now, the search box has decided it will appear in the next line, and the Logout also appears in the second line, like so:
MyProfile Link1 Link2
| search box | Logout
Any help on how to horizontally align after jQuery autocomplete support is appreciated.
I followed the approach in the accepted answer in this SO post. That seems to have solved my problem. The CSS properties of .ui-widget (the jQuery div element) can be additionally changed (for font size etc.) in your application, that is another way you can remove the issues from including that dependency.