I am doing a project on ionic. It is a quiz type app. I have scrollable div on the top which contains all the question numbers. Below that I have cards where questions are appearing. The screenshot is below :
The cards have swipable feature in it that users can swipe the cards to and fro.
My requirement is when the user selects a particular question from the top question number panel, corresponding questions should show and the selected question should be highlighted. Also when the user swipes the cards, the selection of the question numbers in the top should also change.
I created a circle using css for the above panel and using ng-repeat, I am repeating the question numbers. I added a ng-click option on the question number and passing the index. So that I can show the corresponding question. By using this I am able to bind the both panels in one way. I need to bind it reverse too. So that when user swipes the card, the question number should change.
Also I need to highlight a particular item in ng-repeat to show that that is selected. I tried :hover property in css, it somehow highlighting the selected item but not as good as expected.
Here is my code:
angular.module('quiz', ['ionic'])
.controller('QuizController', function($scope) {
$scope.nodes = [{
count: 1,
disabled: false
}, {
count: 2,
disabled: false
}, {
count: 3,
disabled: false
}, {
count: 4,
disabled: false
}, {
count: 5,
disabled: true
}];
$scope.goToQuestionNumber = function(index) {
console.log('goToQuestionNumber: ', index);
$scope.currentQuestion = index;
$scope.act_type = $scope.quiz.clues[$scope.currentQuestion].act_type;
$scope.isActive = $scope.nodes[index];
changeTemplate();
}
$scope.next = function() {
if ($scope.currentQuestion != ($scope.nodes.length - 1)) {
$scope.currentQuestion++;
$scope.currentTry = 1;
$scope.act_type = $scope.quiz.clues[$scope.currentQuestion].act_type;
$scope.failureResult = false;
changeTemplate();
}
}
$scope.prev = function() {
if ($scope.currentQuestion != 0) {
$scope.additionalActivity = false;
$scope.addtionalQuestionAvailability = false;
console.log('Left swipe');
$scope.currentQuestion = $scope.currentQuestion - 1;
$scope.currentTry = 1;
$scope.act_type = $scope.quiz.clues[$scope.currentQuestion].act_type;
$scope.failureResult = false;
changeTemplate();
}
}
})
.events {
position: relative;
}
.event,
span .event,
.event span {
content: "";
float: left;
position: relative;
padding: 3%;
margin: 0% 2% 0% 2%;
border-radius: 50%;
background-color: lightgrey;
border: 3px solid darkgray;
top: 15%;
left: 2%;
font-size: 15px;
z-index: 1;
text-align: center;
line-height: 150%;
color: hotpink;
}
.slider-column {
position: relative;
display: flex;
flex: 0 0 30%;
}
.slider-column::after {
content: '';
height: 3px;
width: 100%;
background-color: #66a3ff;
position: absolute;
top: 45%;
z-index: -5;
margin-left: 0%;
border-radius: 1% 1% 1% 1%;
padding: 1%;
}
.slider-column:last-child:after {
content: '';
height: 2%;
width: 100%;
background-color: transparent;
position: absolute;
top: 30%;
}
/*.event::after{
content:'';
height:3px;
width:170%;
background-color:#6d6dff;
position: absolute;
top: 45%;
z-index: -5;
margin-left: 55%;
border-radius: 1% 1% 1% 1%;
padding: 1%;
}*/
.event::before {
content: '';
height: 5px;
width: 100%;
background-color: transparent;
position: absolute;
top: 30%;
z-index: -5;
padding-left: 10%;
}
.events:first-child:before {
content: '';
height: 5px;
width: 100%;
background-color: transparent;
position: absolute;
top: 30%;
}
.events:last-child-1:after {
content: '';
height: 5px;
width: 100%;
background-color: transparent;
position: absolute;
top: 30%;
}
.timeline-text {
z-index: 4;
top: 0;
bottom: 5px;
}
.enabled-event {
background: red;
}
.event:hover {
border-color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.0/js/ionic.bundle.min.js"></script>
<ion-content ng-app="quiz" ng-controller="QuizController">
<div style="padding-top:10px;padding-left:5px;">
<label class="hamburger" style="float:left">Score:{{totalPoints}} pts</label>
<button style="float:right" class="button button-clear button-small bonus-button" ng-click="bonus()">Try Bonus</button>
</div>
<br>
<br>
<ion-scroll direction="x" class="timeline-scroll">
<div class="timeline">
<div class="events row">
<div class="slider-column" ng-repeat="count in nodes">
<span class="event " ng-click="goToQuestionNumber($index)" ng-if="!count.disabled">
{{count.count}}/{{nodes.length}}
</span>
<span class="event" ng-click="goToQuestionNumber($index)" ng-if="count.disabled">
{{count.count}}/{{nodes.length}}
<!-- </span> -->
</div>
</div>
</div>
</ion-scroll>
<br>
<br>
<div ng-include="currentClueTemplate" ng-swipe-right="prev()" ng-swipe-left="next()" class="question-card"></div>
</ion-content>
Can anyone help me ?
Related
I have carousel testimonial, the carousel is working with click on right left arrow, I want auto slide images and particular testimonial person need to heading in top of image and description in bottom of image, as per image slide, heading and description should shows in middle of testimonial for each testimonial member, I have attached the image for reference, of someone have any testimonial section like this so please share with me, please help really appreciated[
<script>
const galleryContainer = document.querySelector('.gallery-container');
const galleryControlsContainer = document.querySelector('.gallery-controls');
const galleryControls = ['previous', 'add', 'next'];
const galleryItems = document.querySelectorAll('.gallery-item');
class Carousel {
constructor(container, items, controls) {
this.carouselContainer = container;
this.carouselControls = controls;
this.carouselArray = [...items];
}
updateGallery() {
this.carouselArray.forEach(el => {
el.classList.remove('gallery-item-1');
el.classList.remove('gallery-item-2');
el.classList.remove('gallery-item-3');
el.classList.remove('gallery-item-4');
el.classList.remove('gallery-item-5');
});
this.carouselArray.slice(0, 5).forEach((el, i) => {
el.classList.add(`gallery-item-${i+1}`);
});
}
setCurrentState(direction) {
if (direction.className == 'gallery-controls-previous') {
this.carouselArray.unshift(this.carouselArray.pop());
} else {
this.carouselArray.push(this.carouselArray.shift());
}
this.updateGallery();
}
setControls() {
this.carouselControls.forEach(control => {
galleryControlsContainer.appendChild(document.createElement('button')).className = `gallery-controls-${control}`;
document.querySelector(`.gallery-controls-${control}`).innerText = control;
});
}
useControls() {
const triggers = [...galleryControlsContainer.childNodes];
triggers.forEach(control => {
control.addEventListener('click', e => {
e.preventDefault();
if (control.className == 'gallery-controls-add') {
const newItem = document.createElement('img');
const latestItem = this.carouselArray.length;
const latestIndex = this.carouselArray.findIndex(item => item.getAttribute('data-index') == this.carouselArray.length)+1;
Object.assign(newItem,{
className: 'gallery-item',
src: `#{this.carouselArray.length+1}`
});
newItem.setAttribute('data-index', this.carouselArray.length+1);
this.carouselArray.splice(latestIndex, 0, newItem);
document.querySelector(`[data-index="${latestItem}"]`).after(newItem);
this.updateGallery();
} else {
this.setCurrentState(control);
}
});
});
}
}
const exampleCarousel = new Carousel(galleryContainer, galleryItems, galleryControls);
exampleCarousel.setControls();
// exampleCarousel.setNav();
exampleCarousel.useControls();
</script>
.gallery {
width: 100%;
position: relative;
}
.gallery-container {
align-items: center;
display: flex;
height: 400px;
margin: 0 auto;
max-width: 1000px;
position: relative;
}
.gallery-item {
height: 150px;
opacity: 0;
position: absolute;
transition: all 0.3s ease-in-out;
width: 100px;
z-index: 0;
}
.gallery-item-1 {
left: 15%;
opacity: .4;
transform: translateX(-50%);
margin-top: 150px;
}
.gallery-item-2,
.gallery-item-4 {
height: 150px;
opacity: 1;
width: 100px;
z-index: 1;
}
.gallery-item-2 {
left: 30%;
transform: translateX(-88%);
margin-top: 150px;
}
.gallery-item-3 {
box-shadow: 0 0 30px rgba(255, 255, 255, 0.6), 0 0 60px rgba(255, 255, 255, 0.45), 0 0 110px rgba(255, 255, 255, 0.25), 0 0 100px rgba(255, 255, 255, 0.1);
height: 250px;
opacity: 1;
left: 50%;
transform: translateX(-50%);
width: 350px;
z-index: 2;
margin-top: 50px;
}
.gallery-item-4 {
left: 70%;
transform: translateX(-12%);
margin-top: 150px;
}
.gallery-item-5 {
left: 85%;
opacity: .4;
transform: translateX(-48%);
margin-top: 150px;
}
.gallery-controls {
display: flex;
justify-content: center;
margin: 30px 0;
}
.gallery-controls button {
background-color: transparent;
border: 0;
cursor: pointer;
font-size: 16px;
margin: 0 20px;
padding: 0 12px;
text-transform: capitalize;
}
.gallery-controls-next{
position: absolute!important;
right: 8%;
top: 58%;
}
.gallery-controls-previous {
position: absolute!important;
left: 8%;
top: 58%;
}
.gallery-controls button:focus {
outline: none;
}
.gallery-controls-previous {
position: relative;
}
.gallery-controls-previous::before {
border: solid #ffc20e;
border-width: 0 2px 2px 0;
content: '';
display: inline-block;
height: 15px;
left: -10px;
padding: 2px;
position: absolute;
top: 0;
transform: rotate(135deg) translateY(-50%);
transition: left 0.15s ease-in-out;
width: 15px;
}
.gallery-controls-previous:hover::before {
left: -18px;
}
.gallery-controls-next {
position: relative;
}
.gallery-controls-next::before {
border: solid #ffc20e;
border-width: 0 2px 2px 0;
content: '';
display: inline-block;
height: 15px;
padding: 2px;
position: absolute;
right: -10px;
top: 50%;
transform: rotate(-45deg) translateY(-50%);
transition: right 0.15s ease-in-out;
width: 15px;
}
.gallery-controls-next:hover::before {
right: -18px;
}
.gallery-nav {
bottom: -15px;
display: flex;
justify-content: center;
list-style: none;
padding: 0;
position: absolute;
width: 100%;
}
.gallery-nav li {
background: #ccc;
border-radius: 50%;
height: 10px;
margin: 0 16px;
width: 10px;
}
.gallery-nav li.gallery-item-selected {
background: #555;
}
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-6">
<div class="gallery">
<div class="testimonial-bg"></div>
<div class="gallery-container">
<img class="gallery-item gallery-item-1" src="images/events/guest.jpg" data-index="1">
<img class="gallery-item gallery-item-2" src="images/events/guest.jpg" data-index="2">
<img class="gallery-item gallery-item-3" src="images/events/guest.jpg" data-index="3">
<img class="gallery-item gallery-item-4" src="images/events/guest.jpg" data-index="4">
<img class="gallery-item gallery-item-5" src="images/events/guest.jpg" data-index="5">
</div>
<div class="gallery-controls"></div>
</div>
</div>
</div>
</div>
]1
See the below code, I have added auto slide functionality with interval time 5 seconds.
If you want to change the interval, Please update the setInterval time in the "constructor" and "setCurrentState" functions.
<script>
const galleryContainer = document.querySelector('.gallery-container');
const galleryControlsContainer = document.querySelector('.gallery-controls');
const galleryControls = ['previous', 'add', 'next'];
const galleryItems = document.querySelectorAll('.gallery-item');
class Carousel {
constructor(container, items, controls) {
this.carouselContainer = container;
this.carouselControls = controls;
this.carouselArray = [...items];
this.mySlideInterval = null;
this.mySlideInterval = setInterval(
this.autoSlide.bind(this),
5000
);
}
autoSlide() {
this.carouselArray.push(this.carouselArray.shift());
this.updateGallery();
}
updateGallery() {
this.carouselArray.forEach(el => {
el.classList.remove('gallery-item-1');
el.classList.remove('gallery-item-2');
el.classList.remove('gallery-item-3');
el.classList.remove('gallery-item-4');
el.classList.remove('gallery-item-5');
});
this.carouselArray.slice(0, 5).forEach((el, i) => {
el.classList.add(`gallery-item-${i+1}`);
});
}
setCurrentState(direction) {
if (direction.className == 'gallery-controls-previous') {
this.carouselArray.unshift(this.carouselArray.pop());
} else {
this.carouselArray.push(this.carouselArray.shift());
}
clearInterval(this.mySlideInterval);
this.updateGallery();
this.mySlideInterval = setInterval(
this.autoSlide.bind(this),
5000
);
}
setControls() {
this.carouselControls.forEach(control => {
galleryControlsContainer.appendChild(document.createElement('button')).className = `gallery-controls-${control}`;
document.querySelector(`.gallery-controls-${control}`).innerText = control;
});
}
useControls() {
const triggers = [...galleryControlsContainer.childNodes];
triggers.forEach(control => {
control.addEventListener('click', e => {
e.preventDefault();
if (control.className == 'gallery-controls-add') {
const newItem = document.createElement('img');
const latestItem = this.carouselArray.length;
const latestIndex = this.carouselArray.findIndex(item => item.getAttribute('data-index') == this.carouselArray.length)+1;
Object.assign(newItem,{
className: 'gallery-item',
src: `#{this.carouselArray.length+1}`
});
newItem.setAttribute('data-index', this.carouselArray.length+1);
this.carouselArray.splice(latestIndex, 0, newItem);
document.querySelector(`[data-index="${latestItem}"]`).after(newItem);
this.updateGallery();
} else {
this.setCurrentState(control);
}
});
});
}
}
const exampleCarousel = new Carousel(galleryContainer, galleryItems, galleryControls);
exampleCarousel.setControls();
// exampleCarousel.setNav();
exampleCarousel.useControls();
</script>
Slick Carousel (Next/Prev Button Placement)
<div class="container">
<div id="carousel" class="carousel">
<div class="item red"></div>
<div class="item orange"></div>
<div class="item green"></div>
<div class="item blue"></div>
</div>
</div>
$('#carousel').slick({
arrows: true,
slidesToShow: 3
});
Link
Everything is working fine , but i wanted to ask is that how do i make the Next Previous button are placed in the box instead of outside (see example below)
What I wanted:
The Button is on the image (like the example below) - DONE + a button with opacity when user hover
Example :
you should add first this style
First-Step
.slick-prev, .slick-next {
top: auto;
bottom: 25px;
right: 35px;
z-index: 10;
}
Second-Step
.slick-prev {
left: 30px;
}
Third-Step
.slick-next {
right: 30px;
}
Everybody else already gave you the right answer, but since there seems to be something wrong with JS Fiddle right now, I'll throw the code in a snippet for you.
Also, due to the way these snippets include the CSS, the Slick styles were overwriting the ones added here. So I had to make them !important.
$('#carousel').slick({
arrows: true,
slidesToShow: 3
});
.slick-prev::before, .slick-next::before { color: black; }
.container {
width: 600px;
margin-left: 20px;
}
.carousel {
width: 100%;
border: 1px solid black;
}
.item, .content { height: 200px !important; }
.red { background: red; }
.orange { background: orange; }
.green { background: green; }
.blue { background: blue; }
.carousel-2 .item { margin-right: 15px; }
.carousel-3 .item .content { margin-right: 15px; }
/* Not CSS for carousel, but CSS to get the look I want Slick to manage automatically for me. */
.carousel-4 .item {
float: left;
margin-right: 15px;
width: 180px;
}
.carousel-4 .item:nth-child(3) { margin-right: 0; }
.slick-prev, .slick-next {
top: auto !important;
bottom: 0 !important;
z-index: 10 !important;
opacity: 0.5 !important;
}
.slick-next {
right: 0 !important;
}
.slick-prev {
left: 0 !important;
}
.slick-prev:hover, .slick-next:hover {
opacity: 1 !important;
}
<link href="https://cdn.jsdelivr.net/jquery.slick/1.3.6/slick.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://kenwheeler.github.io/slick/slick/slick.js"></script>
<!-- Standard carousel where Slick calculated the best widths to fit. -->
<div class="container">
<div id="carousel" class="carousel">
<div class="item red"></div>
<div class="item orange"></div>
<div class="item green"></div>
<div class="item blue"></div>
</div>
</div>
Looking at your sketch, add the following CSS classes:
.slick-prev {
left: 10px;
top: 180px;
z-index: 1000;
}
.slick-next {
right: 10px;
top: 180px;
z-index: 1000;
}
For the opacity on hover add:
.slick-prev:hover, .slick-next:hover {
opacity: 0.5;
}
.container .slick-arrow {
top: auto;
bottom: 0;
z-index: 100;
opacity: 0;
}
.container .slick-arrow:hover {
opacity: 1;
}
.container .slick-prev {
left: 0;
}
.container .slick-next {
right: 0;
}
Add the following to your css. You can change the 0 for bottom, right and left to whatever offset you'd like.
.slick-prev, .slick-next {
top:auto;
bottom: 0;
z-index: 10;
}
.slick-next {
right: 0;
}
.slick-prev {
left: 0;
}
.slick-prev:hover, .slick-next:hover {
opacity:0.5;
}
If you want to remove the extra space where the buttons used to be then change .container to the this:
.container { width: 570px; }
Fiddle
adding below styling to css will move arrows to location in your image.
/* to align arrow at bottom */
.slick-prev{
left: 10px;
z-index: 1;
top: 100%;
transform: translateY(-100%);
}
.slick-next{
right: 10px;
z-index: 1;
top: 100%;
transform: translateY(-100%);
}
if you want arrow to be opaced by default and visible on hover add below style.
/* to add opacity on default and remove it on hover */
.slick-prev,
.slick-next{
opacity: 0.5;
}
.slick-prev:hover,
.slick-next:hover{
opacity: 1;
}
In my previous question I asked about how to play video in an iFrame, and got an answer : How to click from a video link and let it play in an area below?
But now I'm facing another problem, I have an iFrame and a close [ x ] button [ inspired by : http://jsfiddle.net/EFbzY/1/ ], yet I can't figure out how to activate that close button to close the iFrame, the html and script code at the end of my site looks like this, it's used to control the iFrame :
<div id="modal" tabindex="-1">
<button type="button" data-dismiss="modal" class="close" title="close">×</button>
<div class="content">
<h4 class="title"></h4>
<iframe class="yt-video" src="https://www.youtube.com/embed/A1nRiiWYgZw" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<div id="fade" class="black_overlay" onclick="closeLightBox()" style="display: block;">
<div style=" z-index: 0; left: 76%; top: 17%; width: 22px; position: absolute;">
<h2>×</h2>
</div>
</div>
</div>
<script>
var modal = document.getElementById('modal'),
closeBtn = modal.querySelector('close'),
ytVideo = modal.querySelector('.content .yt-video'),
title = modal.querySelector('.content .title'),
anchors = document.querySelectorAll('a[data-target="modal"]'),
l = anchors.length;
for (var i = 0; i < l; i++)
{
anchors[i].addEventListener("click", function(e)
{
e.preventDefault();
title.textContent = this.dataset.videoTitle || 'No title';
ytVideo.src = this.href;
modal.classList.toggle('is-visible');
modal.focus();
});
}
modal.addEventListener("keydown", function(e)
{
if (e.keyCode == 27)
{
title.textContent = '';
ytVideo.src = '';
this.classList.toggle('is-visible');
}
});
closeBtn.addEventListener("click", function(e)
{
e.preventDefault();
title.textContent = '';
ytVideo.src = '';
modal.classList.toggle('is-visible');
});
</script>
The style code [ at the top of the page ] looks like this :
#modal {
display: none;
position: fixed;
width: 100vw;
height: 100vh;
max-height: 100vh;
top: 0;
left: 0;
background: rgba(24, 24, 24, .6);
z-index: 999;
}
#modal .content {
width: 55%;
height: 65vh;
margin: auto; /* allows horyzontal and vertical alignment as .content is in flex container */
}
#modal .content .yt-video {
display: block;
width: 100%;
height: calc(100% - 45px);
}
#modal .content .title {
box-sizing: border-box;
height: 45px;
line-height: 23px;
padding: 12px 4px;
margin: 0;
background: #007bff;
max-width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#modal .close {
position: absolute;
top: 0;
right: 0;
width: 35px;
height: 35px;
line-height: 35px;
text-align: center;
border: 0;
font-weight: bold;
font-size: 24px;
color: #fff;
background: #666;
cursor: pointer;
transition: background .4s;
}
#modal .close:hover, #modal .close:active {
background: #ef3658;
}
#modal.is-visible {
display: flex;
}
The test site is live at : http://gatecybertech.com/test
At the upper right of the site, click on the "Videos" link will take you to the section, after you click on a video, an iFrame opens and plays the video with a [x] button on the top right corner, but it's not activated, how to fix it so it an close the iFrame and video ?
OK, after some research and experiment, I finally got it. It's running at : http://gatecybertech.com/test later will be moved to the main site : http://gatecybertech.com
[1] Style looks like this :
#modal {
display: none;
position: fixed;
width: 100vw;
height: 100vh;
max-height: 100vh;
top: 0;
left: 0;
background: rgba(24, 24, 24, .6);
z-index: 999;
}
#modal .content {
width: 55%;
height: 65vh;
margin: auto; /* allows horyzontal and vertical alignment as .content is in flex container */
}
#modal .content .yt-video {
display: block;
width: 100%;
height: calc(100% - 45px);
}
#modal .content .title {
box-sizing: border-box;
height: 45px;
line-height: 23px;
padding: 12px 4px;
margin: 0;
background: #007bff;
color: #fff;
text-align: center;
font-size: 26px;
max-width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#modal .close {
position: absolute;
top: 0;
right: 0;
width: 58px;
height: 58px;
line-height: 35px;
text-align: center;
border: 0;
font-weight: bold;
font-size: 26px;
color: #fff;
background: #366;
cursor: pointer;
transition: background .2s;
}
#modal .close:hover, #modal .close:active {
background: #ef3658;
}
#modal.is-visible {
display: flex;
}
[2] Html looks like this :
<div class="tools-icon">
<img src=https://i.ytimg.com/vi/IgBIaZgoAQc/hqdefault.jpg?sqp=-oaymwEXCPYBEIoBSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLDW3KcjXsTR5utmlvhFfibLe-bvRg width=170 height=110>
<p class="tools-icon__text">Keypad Pins Easily Stolen</p>
</div>
...
<!-- the modal div that will open when an anchor link is clicked to show the related video in an iframe. -->
<div id="modal" tabindex="-1">
<div class="content">
<h4 class="title"></h4>
<iframe class="yt-video" src="https://www.youtube.com/embed/A1nRiiWYgZw" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<div class="black_overlay" onclick="closeLightBox()" style="display: block;">
<div style=" z-index: 0; left: 76%; top: 17%; width: 22px; position: absolute;">
<a class="close" onclick = "return close_iFrame();"><h2>×</h2></a>
</div>
</div>
</div>
[3] Script looks like this :
<script>
var modal = document.getElementById('modal'),
closeBtn = modal.querySelector('close'),
ytVideo = modal.querySelector('.content .yt-video'),
title = modal.querySelector('.content .title'),
anchors = document.querySelectorAll('a[data-target="modal"]'),
l = anchors.length;
for (var i = 0; i < l; i++)
{
anchors[i].addEventListener("click", function(e)
{
e.preventDefault();
title.textContent = this.dataset.videoTitle || 'No title';
ytVideo.src = this.href;
modal.classList.toggle('is-visible');
modal.focus();
});
}
modal.addEventListener("keydown", function(e)
{
if (e.keyCode == 27)
{
title.textContent = '';
ytVideo.src = '';
this.classList.toggle('is-visible');
}
});
</script>
<script language="javascript" type="text/javascript">
function close_iFrame()
{
var modal = document.getElementById('modal'),
ytVideo = modal.querySelector('.content .yt-video');
ytVideo.src = '';
modal.classList.toggle('is-visible');
}
</script>
I have this HTML :
Option 1
When I hover it, I can read http://localhost/#MyHash
And when I click on it, the url in the browser is http://localhost/#/MyHash
Why is this slash added ? Is there a workaround ?
I couldn't figure it out...
Extra :
It's a .NET MVC web solution with AngularJS, I don't know if this is relevant
I saw some topic about googlebot / SEO (URL fragments: a leading slash in your hash url - good or bad?) : I don't care about it, this is not for a public website.
Edit :
See it in JSFiddle : https://jsfiddle.net/y2nLaxh5/embedded/result/
Hover the green part an look on options proposed
(as it is in an iframe you should open in a new tab)
Edit2 :
(function () {
var app = angular.module("myApp", []);
app.controller("MenuController", ['$scope', function($scope) {
$scope.items = [
{
name: "Option 1",
url: 'MyUrl'
},
{
name: "Option 2",
url: 'MyUrl',
items: [
{
name: "SubOption 2-1"
}
]
}
];
function preprocessItems(items, depth) {
depth = typeof(depth) === "undefined" ? 0 : depth;
for (var i in items) {
items[i].depth = depth;
preprocessItems(items[i].items, depth + 1);
}
}
preprocessItems($scope.items);
}]);
})();
body {
font-size: .85em;
font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
color: #CCC;
background-color: #333;
}
#background
{
position: fixed;
top: 15%;
bottom: 15%;
left: 15%;
right: 15%;
}
#LeftMenu
{
height: 100%;
position: fixed;
left: 0;
top: 0;
width: 0;
}
#LeftMenu > .MenuContent
{
position: absolute;
width: 0;
height: 100%;
z-index:1;
}
#LeftMenu > .MenuContent > .MenuSlider
{
background-color: #000;
left: -200px;
position: relative;
width: 200px;
height: 100%;
padding: 10px 20px;
box-sizing: border-box;
transition: left 0.3s ease-out;
}
#LeftMenu:hover > .MenuContent > .MenuSlider
{
left: 0;
}
.MenuSlider h3
{
margin: 0 0 10px 0;
text-align: center;
}
.MainIcon
{
display: block;
text-decoration: none;
padding: 10px;
border-radius: 0 0 5px 0;
background-color: #1fa67a;
width: 200px;
height: auto;
box-sizing: border-box;
font-family: 'Nixie One';
font-size: 2em;
font-weight: bold;
color: #FFF;
}
.MainIcon > p
{
margin: 0;
}
.Activator
{
position: absolute;
right: 0;
top: 0;
height: 100%;
}
.ActivatorCirle
{
position: absolute;
height: 400px;
top: -200px;
width: 400px;
left: -200px;
border-radius: 100%;
}
.ActivatorColumn
{
position: absolute;
height: 100%;
top: 0;
width: 30px;
left: 0;
}
.menuItem.dpt0 { font-size: 1.2em; }
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script type="text/ng-template" id="menuItem_renderer.html">
{{item.name}}
<div ng-if="item.items">
<div ng-repeat="item in item.items" ng-include="'menuItem_renderer.html'"></div>
</div>
</script>
<body ng-app="myApp">
<div id="background"></div>
<div id="LeftMenu" ng-controller="MenuController as menu">
<div class="Activator">
<div class="ActivatorCirle"></div>
<div class="ActivatorColumn"></div>
</div>
<div class="MenuContent">
<a class="MainIcon" href="/">
<p>Media<br />Content<br />Supervisor</p>
</a>
<div class="MenuSlider">
<h3>MENU</h3>
<div ng-repeat="item in items" ng-include="'menuItem_renderer.html'"></div>
</div>
</div>
</div>
</body>
I want to arrange 4 buttons (or bootstrap tabs,doesn't matter) around a circle and load a content in the middle of that circle,something like this:
How can i do that?
you could use a small bit of jquery to load your center circle with the text you want.
$(document).ready(function() {
$('.quart').click(function() {
var ind = $(this).index();
switch (ind) {
case 0:
var tex = "div 1";
break;
case 1:
var tex = "div 2";
break;
case 2:
var tex = "div 3";
break;
case 3:
var tex = "div 4";
break;
}
$('.center').text(tex);
});
});
.wrap {
height: 300px;
width: 300px;
border-radius: 50%;
position: relative;
overflow: hidden;
}
.quart {
position: absolute;
height: 50%;
width: 50%;
background: tomato;
transition: all 0.4s;
}
.quart:first-child {
top: 0;
left: 0;
}
.quart:nth-child(2) {
top: 0;
left: 50%;
}
.quart:nth-child(3) {
top: 50%;
left: 0;
}
.quart:nth-child(4) {
top: 50%;
left: 50%;
}
.center {
height: 80%;
width: 80%;
position: absolute;
top: 10%;
left: 10%;
background: lightgray;
border-radius: 50%;
text-align: center;
line-height: 160px;
}
.quart:hover {
background: dimgray;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrap">
<div class="quart"></div>
<div class="quart"></div>
<div class="quart"></div>
<div class="quart"></div>
<div class="center">Click My non-existent Corners!</div>
</div>
This probably won't be as efficient as an svg solution, but colud be altered to your needs.
You can use the HTML <map> tag - more info