I try to load using jQuery and Ajax a div located in another file. I can load the hole file, I can load the div with text inside it, but I want 3 divs to the respective navbar, what should I do???
HTML :
<div class="container">
<ul class="tab-navigation">
<li>Trang chủ</li>
<li>Giới thiệu</li>
<li>Liên hệ</li>
</ul>
</div>
<div id="main-content"></div>
files html i need into :
<div id="home" class="tab-content">
<p><b>Home</b> Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur, deleniti aliquid? Rerum excepturi quod cupiditate quam magnam necessitatibus dignissimos culpa ab ex nesciunt repellat, perspiciatis iure cum tempora vero perferendis?</p>
</div>
<div id="contact" class="tab-content">
<p><b>Contact</b> Lorem ipsum dolor sit amet consectetur adipisicing elit. Pariatur, deleniti aliquid? Rerum excepturi quod cupiditate quam magnam necessitatibus dignissimos culpa ab ex nesciunt repellat, perspiciatis iure cum tempora vero perferendis?</p>
</div>
<div id="about" class="tab-content">
<p><b>About</b> Lorem ipsum dolor sit ?</p>
</div>
JS
$(document).ready(function(){
$(".tab-navigation li").click(function(){
var index = $(this).index(); // thứ tự tab
console.log(index);
$(this).siblings().removeClass("active");
$(this).addClass("active");
/* ================= Load url ================= */
$(".tab-navigation li").each(function(){
if(index == 0){
$("#main-content").load('files/home.html');
}
if(index == 1){
$("#main-content").load('files/about.html');
}
if(index == 2){
$("#main-content").load('files/contact.html');
}
})
})
})
Related
I have a slider with 3 slides for now. I want those 3 slides to be on the same rows or to be moved to the same row without position: absolute.
Live fiddle: https://jsfiddle.net/5z167ypt
HTML:
<div class="slider">
<div class="slide active-slide">
<h2>Slide 1</h2>
<img src="https://place-hold.it/100">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae reiciendis maiores quia excepturi doloribus fugit nemo in inventore quidem at modi quasi rerum nulla ut, ab libero adipisci sint dolores.</p>
</div>
<div class="slide slide-right">
<h2>Slide 2</h2>
<img src="https://place-hold.it/100">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae reiciendis maiores quia excepturi doloribus fugit nemo in inventore quidem at modi quasi rerum nulla ut, ab libero adipisci sint dolores.</p>
</div>
<div class="slide slide-right">
<h2>Slide 3</h2>
<img src="https://place-hold.it/100">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae reiciendis maiores quia excepturi doloribus fugit nemo in inventore quidem at modi quasi rerum nulla ut, ab libero adipisci sint dolores.</p>
</div>
</div><!-- .slider -->
<div class="controlers">
<button id="next">Next</button>
<button id="previous">Previous</button>
</div><!-- .controlers -->
CSS:
.slider,
.controlers{
width: 80%;
margin: auto;
overflow: hidden;
}
.slide{
position: relative;
width: 100%;
float: left;
transform: translateX(0);
transition: 1s transform ease-in-out;
text-align: center;
}
.slide-left{
transform: translateX(-100vw);
}
.slide-right{
transform: translateX(100vw);
}
jQuery:
//On clicking #next button
$('#next').click(function(){
var current = $('.active-slide'),
next = $('.active-slide').next();
//Move current active slide to the left & remove active class
current.removeClass('active-slide').addClass('slide-left');
//Add active class to nect slide to be in the center & remove slide classes
next.addClass('active-slide').removeClass('slide-right slide-left');
});
//On clicking #previous button
$('#previous').click(function(){
var current = $('.active-slide'),
previous = $('.active-slide').prev();
//Move current active slide to the right & remove active class
current.removeClass('active-slide').addClass('slide-right');
//Add active class to previous slide to be in the center & remove slide classes
previous.addClass('active-slide').removeClass('slide-right slide-left');
});
For now, The 3 slides are divided into 3 rows. Each slide is moving right and left in a separate row. I want all the 3 slides to be moving in the same row.
You can use plugin for slider. Like Slick Slider
<script src="https://code.jquery.com/jquery-3.6.0.min.js"/>
<script src="https://cdn.jsdelivr.net/npm/slick-carousel#1.8.1/slick/slick.min.js"/>
$('.slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
dots: true,
});
<div class="slider">
<div class="slide active-slide">
<h2>Slide 1</h2>
<img src="https://place-hold.it/100">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae reiciendis maiores quia excepturi doloribus fugit nemo in inventore quidem at modi quasi rerum nulla ut, ab libero adipisci sint dolores.</p>
</div>
<div class="slide slide-right">
<h2>Slide 2</h2>
<img src="https://place-hold.it/100">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae reiciendis maiores quia excepturi doloribus fugit nemo in inventore quidem at modi quasi rerum nulla ut, ab libero adipisci sint dolores.</p>
</div>
<div class="slide slide-right">
<h2>Slide 3</h2>
<img src="https://place-hold.it/100">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae reiciendis maiores quia excepturi doloribus fugit nemo in inventore quidem at modi quasi rerum nulla ut, ab libero adipisci sint dolores.</p>
</div>
</div>
I am using Bootstrap 5 row property to make my website responsive. However, when I try to add 2 divs next to each other, they don't seem to align at the very center of the webpage, instead, there is quite an unused gap at the right that I can't get rid of. For this section I am using class="container". Any tips? Code below. I also added an image of how it looks when I inspect.
<h1> (SPH) </h1>
<div class="row">
<div class="box col-lg-6">
<h3> Who We Are </h3>
<p> Lorem, ipsum dolor sit amet consectetur adipisicing elit. Possimus fuga repellendus minima maiores beatae unde odit eius in sint optio. Ipsum optio neque beatae quod necessitatibus dolor iste quae voluptatibus. </p>
</div>
<div class="box col-lg-6">
<h3> What We Do </h3>
<p> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ipsam saepe illum dolores corporis suscipit enim at non temporibus perspiciatis corrupti dicta pariatur, veritatis beatae error doloremque voluptates. Eius, eveniet accusantium. </p>
</div>
</div>
As mentioned in the comments.
You can use a class at the top of your page like : container.
Example:
<div class= container justify-content-center> /your code here/ </div>
The other answer has a few semantic issues so I'd figured I post one. Essentially, you should nest your Bootstrap row into a container. Then you can add justify-content-center on the row because it has a display: flex; by default.
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<div class="container">
<h1 class="text-center"> (SPH) </h1>
<div class="row justify-content-center">
<div class="box col-lg-6">
<h3> Who We Are </h3>
<p> Lorem, ipsum dolor sit amet consectetur adipisicing elit. Possimus fuga repellendus minima maiores beatae unde odit eius in sint optio. Ipsum optio neque beatae quod necessitatibus dolor iste quae voluptatibus. </p>
</div>
<div class="box col-lg-6">
<h3> What We Do </h3>
<p> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ipsam saepe illum dolores corporis suscipit enim at non temporibus perspiciatis corrupti dicta pariatur, veritatis beatae error doloremque voluptates. Eius, eveniet accusantium. </p>
</div>
</div>
</div>
I have a video . I have placed a text "Click Me" at the center of the video.
My requirement is - on clicking on the "Click Me" or any part of the video , the video should play and "Click Me" disappear.
.banner-description{
position: absolute;
font-weight: bold;
top : 50%;
left: 50%;
background: rebeccapurple;
}
.video-banner{
position: relative;
}
<body>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Corporis laudantium nobis laboriosam quaerat. Quo, veritatis harum nemo eligendi sed dicta fugiat ad. Voluptas ea maxime qui nostrum blanditiis facere natus!
</div>
<div class="video-banner">
<video controls>
<source src="011-video-files.mp4">
</video>
<div class="banner-description">
<p>Click Me</p>
</div>
</div>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde explicabo repellat minima magnam totam, temporibus nemo saepe praesentium ipsam a quidem. Mollitia vero impedit architecto quod ex voluptates neque eveniet!
</div>
</body>
The problem is : while clicking on the "Click Me" , nothing happens . And , while clicking on some other part of the video, though video starts "Click Me" dose not disappear
Add (click) event to .video-banner and to the video and play() the video in function...
Also add class to click me onclick to hid it as [ngClass]="{'hide': isClicked}"
Here is working stackblitz
HTML
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Corporis laudantium nobis laboriosam quaerat. Quo, veritatis harum nemo eligendi sed dicta fugiat ad. Voluptas ea maxime qui nostrum blanditiis facere natus!
</div>
<div class="video-banner" (click)="play()">
<video controls #videoPlayer>
<source src="011-video-files.mp4">
</video>
<div class="banner-description" (click)="play()" [ngClass]="{'hide': isClicked}">
<p>Click Me</p>
</div>
</div>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde explicabo repellat minima magnam totam, temporibus nemo saepe praesentium ipsam a quidem. Mollitia vero impedit architecto quod ex voluptates neque eveniet!
</div>
TS
#ViewChild('videoPlayer') videoplayer: ElementRef;
isClicked=false;
play() {
this.videoplayer.nativeElement.play();
this.isClicked=true;
}
CSS
.hide{
display:none;
}
Since you use angular you can use *ngIf or *ngShow and with a (click) event you can trigger it
<div (click)="showDescription = !showDescription" class="video-banner">
<video controls>
<source src="011-video-files.mp4">
</video>
<div *ngIf="showDescription" class="banner-description">
<p>Click Me</p>
</div>
</div>
Sea this one click me button is working there is jquery for that to work check this I think it's useful for you
document.getElementById("banner-description").addEventListener("click", changeBackground);
// OTHER FUN STUFF WE CAN DO:
function changeBackground() {
var randomColor = Math.floor(Math.random()*16777215).toString(16);
document.body.style.background = '#' + randomColor;
};
#banner-description{
position: absolute;
font-weight: bold;
top : 50%;
left: 50%;
background: rebeccapurple;
}
.video-banner{
position: relative;
}
<body>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Corporis laudantium nobis laboriosam quaerat. Quo, veritatis harum nemo eligendi sed dicta fugiat ad. Voluptas ea maxime qui nostrum blanditiis facere natus!
</div>
<div class="video-banner">
<video controls>
<source src="011-video-files.mp4">
</video>
<div id="banner-description">
<p>Click Me</p>
</div>
</div>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde explicabo repellat minima magnam totam, temporibus nemo saepe praesentium ipsam a quidem. Mollitia vero impedit architecto quod ex voluptates neque eveniet!
</div>
</body>
I have two columns (one with is-half class) that I want to "stack" (one on top of each other) on mobile AND tablet mode.
As from the documentation I have used <div class="columns is-desktop"></div>
But it is not working properly.. On tablet, columns are stacked but the first column, which has a is-half class, remains half sized.
Here's a snippet to illustrate the issue:
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.css" rel="stylesheet"/>
<div class="container">
<div class="columns is-desktop">
<div class="column is-half">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eligendi nostrum voluptatum porro maiores animi dignissimos amet consectetur cumque sapiente eos, explicabo, accusamus modi mollitia labore corporis inventore eveniet esse quam?
</div>
<div class="column">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto alias necessitatibus doloremque magni minima nobis facere, quibusdam autem eveniet voluptatum amet explicabo voluptates, laudantium praesentium? Ab repellat eius doloremque labore.
</div>
</div>
</div>
Or a JSFiddle Example
I want the is-half column to be fullwidth on tablet mode.
It is not a bug. That's the expected behaviour.
<div class="columns is-desktop"></div>
has display: block until desktop
#media screen and (min-width:1024px){.columns.is-desktop{display:-webkit-box;display:-ms-flexbox;display:flex}}
.is-half has width: 50%
.column.is-half,.column.is-half-tablet{-webkit-box-flex:0;-ms-flex:none;flex:none;width:50%}
It's like
div {
border: 1px solid;
}
.half {
width: 50%;
}
<div class="half">half</div>
<div>fullwidth</div>
between 768px and 1024px.
Solution
(Don't set .is-half)
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css">
<div class="container">
<div class="columns is-desktop">
<div class="column">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eligendi nostrum voluptatum porro maiores animi dignissimos amet consectetur cumque sapiente eos, explicabo, accusamus modi mollitia labore corporis inventore eveniet esse quam?
</div>
<div class="column">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto alias necessitatibus doloremque magni minima nobis facere, quibusdam autem eveniet voluptatum amet explicabo voluptates, laudantium praesentium? Ab repellat eius doloremque labore.
</div>
</div>
</div>
If you want to have other sizes, e.g. for desktop, use .is-x-desktop
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css">
<div class="container">
<div class="columns is-desktop">
<div class="column is-8-desktop">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eligendi nostrum voluptatum porro maiores animi dignissimos amet consectetur cumque sapiente eos, explicabo, accusamus modi mollitia labore corporis inventore eveniet esse quam?
</div>
<div class="column">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto alias necessitatibus doloremque magni minima nobis facere, quibusdam autem eveniet voluptatum amet explicabo voluptates, laudantium praesentium? Ab repellat eius doloremque labore.
</div>
</div>
</div>
Change Class Name is-half to is-half-desktop
<div class="container">
<div class="columns is-desktop">
<div class="column is-half-desktop">
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Eligendi nostrum voluptatum porro maiores animi dignissimos amet consectetur cumque sapiente eos, explicabo, accusamus modi mollitia labore corporis inventore eveniet esse quam?
</div>
<div class="column is-half-desktop">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto alias necessitatibus doloremque magni minima nobis facere, quibusdam autem eveniet voluptatum amet explicabo voluptates, laudantium praesentium? Ab repellat eius doloremque labore.
</div>
</div>
</div>
https://jsfiddle.net/wtprmwsh/2/
I need print page number when printing html in Chrome Version 52.0.2743.116 m (64-bit). However I haven't found the answer yet.
I have already tried this:
#page {
#bottom-right {
content: counter(page) " of " counter(pages);
}
}
This didn't work at all.
Then I have found this Q&A:
For this answer we are not using #page, which is a pure CSS answer, but work in FireFox 20+ versions. Here is the link of an example.
The CSS is:
#content {
display: table;
}
#pageFooter {
display: table-footer-group;
}
#pageFooter:after {
counter-increment: page;
content: counter(page);
}
And the HTML code is:
<div id="content">
<div id="pageFooter">Page </div>
multi-page content here...
</div>
Unfortunately, this works only in FireFox 20+ versions and Chrome Version 35.0.1916.153
Downgrade isn't an answer.
Can you help me, please?
This set up works for me, you just need an element at the end of each page to append a page counter onto.
Code:
HTML:
body {
counter-reset: section;
}
#media print {
.page {
page-break-after: always;
}
.page .pageEnd::after {
counter-increment: section;
/* Increment the section counter*/
content: "Page " counter(section) " ";
/* Display the counter */
}
}
<div class="page">
<h2>Here is page 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 5</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 6</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>
<div class="page">
<h2>Here is page 7</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quas nulla accusantium, veritatis quidem voluptas ex, atque suscipit incidunt, dolore sunt reiciendis cum obcaecati, iste necessitatibus doloribus cumque facere beatae. Ratione?</p>
<div class="pageEnd"></div>
</div>