I have a modal with a dropdown. When clicking the dropdown the modal always gets a scrollbar and I wanted to know if I miss something obvious? I could probably just add a class modalheight and define in css:
.modalheight {
min-height: 400px;
}
but this seems not like a true solution.
function closeModal () {
var modal = document.getElementById("mymodal")
modal.classList.remove("is-active")
};
function activateDropDown () {
var dropdown = document.getElementById("mydropdown");
dropdown.classList.add("is-active")
};
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma#0.9.4/css/bulma.min.css">
<div class="modal is-active" id="mymodal">
<div class="modal-background">
</div>
<div class="modal-content">
<div class="box">
<article class="media">
<div class="media-content">
<div class="content">
this is a test:
<div class="dropdown" id="mydropdown">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu" onclick="activateDropDown()">
<span>Dropdown button</span>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
<a href="#" class="dropdown-item">
test 1
</a>
<a href="#" class="dropdown-item">
test 2
</a>
<a href="#" class="dropdown-item">
test 3
</a>
</div>
</div>
</div>
</div>
</div>
</article>
</div>
</div>
</div>
Can I somehow make the modal big enough to fit all the buttons options dynamically? If not, how would I do it statically?
Check this option, I think the behaviour is connected with the dropdown menu absolute positioning that takes it out of the normal flow. By the way, for button html tag both the starting and ending tag are mandatory.
function closeModal () {
var modal = document.getElementById("mymodal")
modal.classList.remove("is-active")
};
function activateDropDown () {
var dropdown = document.getElementById("mydropdown");
dropdown.classList.toggle("is-active")
};
#dropdown-menu {
position: static;
}
#modal-content {
max-height: none;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma#0.9.4/css/bulma.min.css">
<div class="modal is-active" id="mymodal">
<div class="modal-background">
</div>
<div class="modal-content" id="modal-content">
<div class="box">
<article class="media">
<div class="media-content">
<div class="content">
this is a test:
<div class="dropdown" id="mydropdown">
<div class="dropdown-trigger">
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu" onclick="activateDropDown()"> <span>Dropdown button</span></button>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
<a href="#" class="dropdown-item">
test 1
</a>
<a href="#" class="dropdown-item">
test 2
</a>
<a href="#" class="dropdown-item">
test 3
</a>
</div>
</div>
</div>
</div>
</div>
</article>
</div>
</div>
</div>
Related
I am using Bulma and I made an hoverable dropdown, but the dropdown content exceeds the whole page content. How can I make it fixed with larger width and also responsive?
For now it looks like this:
Html code:
<div class="navbar-end">
<div class="dropdown is-hoverable navbar-item ">
<div class="dropdown-trigger">
<button aria-controls="dropdown-menu6" aria-haspopup="true" class="button is-primary">
<strong>Account</strong>
</button>
</div>
<div class="dropdown-menu has-text-centered" id="dropdown-menu6" role="menu">
<div class="dropdown-content">
<div class="dropdown-item">
<p>Acces your quizbee account, test your skills and have fun. </p>
<hr class="dropdown-divider">
<div class="buttons is-centered">
<button class="button is-primary is-rounded">Register</button>
<button class="button is-light is-rounded">Login</button>
</div>
</div>
</div>
</div>
</div>
You just need to set a position of dropdown. Add class is-right
<div class="dropdown is-right is-active">
In my case, my home page only consists of a menu and closed accordions, each href in the menu when clicked on, opens a specific accordion & this works good.
My question is, if I have the same menu in other pages, not the home page, how can I let it hyperlinks to the home page & opens the specific accordion? They told me it can be done using Local Storage, but I don't know how to use it, any help please?
JQUERY CODE
$(document).ready(function () {
$(".expand").on("click", function () {
$(".right-arrow").text("+");
$(".detail:visible").slideUp();
if (!$(this).next().is(":visible")) {
$(this).next().slideDown(200);
$(this).find(".right-arrow").text("-");
}
});
let click_state = localStorage.getItem("click_state");
let ind = localStorage.getItem("ind");
if (click_state == 1) {
$(".expand").eq(ind).trigger("click");
localStorage.removeItem("click_state");
localStorage.removeItem("ind");
} else {
}
$(".accord").each(function (index) {
$(this).click(function (event) {
event.preventDefault();
localStorage.setItem("click_state", 1);
localStorage.setItem("ind", index);
});
});
});
HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<a class="accord" href=""> Open 1st accordion </a> <br>
<a class="accord" href=""> Open 2nd accordion </a>
<div class="container">
<div class="row" id="accordion1">
<div id="trickslist">
<ul>
<li>
<a class="expand" data-parent="#accordion1">
<div class="right-arrow">+</div>
<div>
<h2 class="tipstricks">Exploring your Motivations to Quit Tobacco</h2>
</div>
</a>
<div class="detail">
</div>
</li>
<li>
<a class="expand" data-parent="#accordion1">
<div class="right-arrow">+</div>
<h2 class="tipstricks">What to expect over time.</h2>
</a>
<div class="detail">
</div>
</li>
<li>
<a class="expand" data-parent="#accordion1">
<div class="right-arrow">+</div>
<h2 class="tipstricks">Getting Ready: Strategies to conquer urges & set a quit date</h2>
</a>
<div class="detail">
</div>
</li>
<li>
<a class="expand" data-parent="#accordion1">
<div class="right-arrow">+</div>
<h2 class="tipstricks">Quitting tobacco with medications</h2>
</a>
<div class="detail">
</div>
</li>
<li>
<a class="expand" data-parent="#accordion1">
<div class="right-arrow">+</div>
<h2 class="tipstricks">Dealing with depression or stress</h2>
</a>
<div class="detail">
</div>
</li>
<li>
<a class="expand" data-parent="#accordion1">
<div class="right-arrow">+</div>
<h2 class="tipstricks">Avoiding weight gain or alcohol</h2>
</a>
<div class="detail">
</div>
</li>
<li>
<a class="expand" data-parent="#accordion1">
<div class="right-arrow">+</div>
<h2 class="tipstricks">Making your plan stick: relapse prevention</h2>
</a>
<div class="detail">
</div>
</li>
</ul>
</div>
</div>
</div>
How can I display page content according to the button I click?
I would like that on entering the page it presents the HTML of a button, but if you click on the other button the page loads another HTML.
I made a very simple example, and I would like the page to load the html inside the container class and then click on another button to load the content of the container-fluid class.
Sorry if I was confused.
Thanks!
My simple example
<li class="nav-item">
<a class="Grelha">
<img src="http://icons.iconarchive.com/icons/hopstarter/button/128/Button-Close-icon.png" style="width:30px; height:30px; cursor:pointer" >
</a>
</li>
<li class="nav-item">
<a class="Vquadrado">
<img src="http://icons.iconarchive.com/icons/hopstarter/button/128/Button-Play-icon.png" style="width:30px; height:30px cursor:pointer">
</a>
</li>
<div class="container">
<div class="row text-center text-lg-left tab-pane">
<div class="col-sm-2">
<a href="#" class="d-block mb-4 h-100">
<img class="Images" src="https://source.unsplash.com/pWkk7iiCoDM/400x300" alt="">
<div class="ImageText"> Name</div>
</a>
</div>
<div class="col-sm-2">
<a href="#" class="d-block mb-4 h-100">
<img class="Images" src="https://source.unsplash.com/aob0ukAYfuI/400x300" alt="">
<div class="ImageText"> Name</div>
</a>
</div>
</div>
</div>
<div class="container-fluid">
<div class="d-flex flex-row flex-wrap" style="margin-left: 3px;">
<div class="d-flex flex-column">
<a>
<img src="https://images.unsplash.com/photo-1485963631004-f2f00b1d6606?auto=format&fit=crop&w=668&q=80" class="img-fluid Vimages">
<div class="VimageText"> Name1</div>
</a>
<a>
<img src="https://images.unsplash.com/photo-1502865787650-3f8318917153?auto=format&fit=crop&w=334&q=80" class="img-fluid Vimages">
<div class="VimageText"> Name1</div>
</a>
</div>
</div>
</div>
You can toggle container with all styles which makes it visible or not.
For example:
display:none;
visibility: hidden;
const button1 = document.querySelector('.toggle-first');
const button2 = document.querySelector('.toggle-second');
const firstContainer = document.querySelector('.first');
const secondContainer = document.querySelector('.second');
button1.addEventListener('click', () => {
firstContainer.style.display = 'block'; // Or visibility: visible or other style
secondContainer.style.display = 'none';
});
button2.addEventListener('click', () => {
secondContainer.style.display = 'block'; // Or visibility: visible or other style
firstContainer.style.display = 'none';
});
<div class="container first">
<h1> First container </h1>
</div>
<button class="toggle-first"> Toggle first container </button>
<div class="container second">
<h1> Second container </h1>
</div>
<button class="toggle-second"> Toggle second contianer </button>
I need to dismiss a ui dropdown while hovering over it. Now, the ui drop down is just visible and never shows or hides when tapped or clicked.
Here are the snippets:
<div ng-show="user" class="ui pointing dropdown link item">
<span class="text">Reg</span>
<i class="dropdown icon"></i>
<div class="menu transition visible">
<a class="item" href="/xyz">
Schools
</a>
<div class="divider"></div>
<a class="item" href="/xyz2">
Admissions
</a>
</div>
</div>
UI drop down is initialized like this:
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.1/components/dropdown.js" type="text/javascript"></script>
<script type="text/javascript">
$('.ui.dropdown')
.dropdown();
</script>
What changes are needed here?
You just need to add the css class simple for hover.
<div ng-show="user" class="ui pointing simple dropdown link item">
<span class="text">Reg</span>
<i class="dropdown icon"></i>
<div class="menu transition visible">
<a class="item" href="/xyz">
Schools
</a>
<div class="divider"></div>
<a class="item" href="/xyz2">
Admissions
</a>
</div>
</div>
And in JS file ,you need to initialize like below
<script>
$(document).ready(function () {
$('.ui.dropdown').dropdown();
})
</script>
I am trying to parse some data and images from controller to show on view. I implemented a foreach loop to show some images in slideshow. But whenever I run the code only the first image appears inside the body, and other images and information goes below the footer. I am not getting what mistake I made in this code.
My code is-
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-10">
<h2>#ViewBag.Title</h2>
<ol class="breadcrumb">
<li class="active">
Back
</li>
</ol>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Search</title>
</head>
<body>
<div>
#foreach (var item in ViewBag.Cities) {
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>#item.Name</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
</div>
</div>
<div class="ibox-content">
<p>#item.Shorttext</p>
</div>
</div>
</div>
foreach (var image in item.Images) {
<div class="col-lg-5">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Animation without caption</h5>
</div>
<div class="ibox-content">
<div class="carousel slide" id="carousel1">
<div class="carousel-inner">
<div class="item active">
<img alt="image" class="img-responsive" src="#image" style="height:400px;width:600px">
</div>
</div>
<a data-slide="prev" href="#carousel1" class="left carousel-control">
<span class="icon-prev"></span>
</a>
<a data-slide="next" href="#carousel1" class="right carousel-control">
<span class="icon-next"></span>
</a>
</div>
</div>
</div>
</div>
} }
</div>
</body>
</html>
My view is looking like this.
Hope it will solve your issue.
<div class="col-lg-10">
<h2>#ViewBag.Title</h2>
<ol class="breadcrumb">
<li class="active">
Back
</li>
</ol>
</div>
</div>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Search</title>
</head>
<body>
<div>
#foreach (var item in ViewBag.Cities) {
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>#item.Name</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
</div>
</div>
<div class="ibox-content">
<p>#item.Shorttext</p>
</div>
</div>
</div>
}
foreach (var image in item.Images) {
<div class="col-lg-5">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>Animation without caption</h5>
</div>
<div class="ibox-content">
<div class="carousel slide" id="carousel1">
<div class="carousel-inner">
<div class="item active">
<img alt="image" class="img-responsive" src="#image" style="height:400px;width:600px">
</div>
</div>
<a data-slide="prev" href="#carousel1" class="left carousel-control">
<span class="icon-prev"></span>
</a>
<a data-slide="next" href="#carousel1" class="right carousel-control">
<span class="icon-next"></span>
</a>
</div>
</div>
</div>
</div>
}
</div>
</body>
</html>