Sticky header under fullscreen div - header

I have a question about a sticky header. On my website I have a "top" div that contains a 100% width/height image. If the user scrolls down, the top div scrolls away and then they can see the main div/content. But I want to have a "sticky" header just under the top div, so that the user dont see the "menu"-header when they are at the top of the page, it should be sticked just under the top image and hook on when the scrolling is "passing by". is this possible to do?
Thank you in advanced!
Here's a piece of my code. I have fixed so that the meny is right under the top picture, but it doesn't follow the scroll. What's the problem?
Thanks!
HTML:
<header id="top">
(The big picture)
</header>
<div id="logo">
<img src="logo" alt="Logo">
</div>
<div class="container">
<div id="sub_header">
<div id="menu1">
Content
</div>
</div>
CSS:
#sub_header { height:53px; width: 100%; padding:5px 0; }
#sub_header.sticky { position:fixed; top:100px; left:0px; right:0px; z-index:99999; }
jQuery:
$(function(){
$(window).scroll(function(){
if ($(window).scrollTop() > body) {
$("#sub_header").addClass("sticky");
} else {
$("#sub_header").removeClass("sticky");
}
});
});

Related

Is there a property that styles margins and positions on the background (vm--overlay) of vue-js-modal?

When vue-js-modal is set to modal Open, the DOM shown below is inserted.
<div class='modal'>
<div class='vm--overlay'></div>
<div class='modal-content'></div>
</div>
Since the header exists on the screen where the modal is inserted,
I want to implement it so that it does not cover the header.
Or No need for it(vm--overlay).
The structure of the DOM is as follows.
<header></header>
<div class='modal'>
<div class='vm--overlay'></div>
<div class='modal-content'></div>
</div>
I was able to apply styles to modal-content,
just like that below
.modal-content {
// same value as header height
margin-top: 50px;
}
But I couldn't apply the style against vm--overlay.
The following didn't work.
.vm--overlay {
// same value as header height
margin-top: 50px;
}
Is there way to remove the vm--overlay or apply the style?
it is a link of properties of vue-js-modal.
https://euvl.github.io/vue-js-modal/Properties.html#properties-2

How to resize vs-popup in the context of vuejs

Im using vs-popup in order to display the contents when ever the button is clicked, but the size of vs-popup is fixed, and my contents looks clumsy, so I want someone to tell me how I can change width of the popup as per my requirement.
<vs-button class="btn" #click=" showModal=true" color="#7367F0" > Click me</vs-button>
<vs-popup class="helundo" title="How will i resize popup" :active.sync="showModal">
<div class="vx-row">
<div class="vx-col w-full md:w-1/2 mb-base">
<p> I want this content in the left</p>
</div>
<div class="vx-col w-full md:w-1/2 mb-base">
<p> I want this content in the right</p>
</div>
</div>
</vs-popup>
<script>
export default {
data () {
return {
showModal: false
}
}
}
</script>
<style>
<!-- what should I add in order to resize the popup -->
</style>
And the output I'm obtaining is sent below:
I want the popup bigger and it should be flexible such that what ever content I add must fit accordingly.
Please do help me, as I am unable to change the width of the popup, what ever I do it is same, but if I add too many contents the width increases for a extend and it becomes scrollable.
I found out the answer myself, i am posting so that it can help others. If you are using vuesax library you might find out _fixesVuesax.scss
so just place this code there:
.con-vs-popup {
z-index: 53000;
.vs-popup {
width: 200px !important; //You can change the width according to your content
height: auto;
}
.vs-popup--content {
width: auto !important;
padding: 1rem;
font-size: 1rem;
}
}

v-cloak does not work in vue.js?

There is a div in my page that for show the error message.When I refresh the page,it will appear for a while then it disappear. I added v-cloak but it doesn't work.
this is the code, showErrorMsg is false
<div v-cloak v-show="showErrorMsg" style="z-index:100" class="h5_tips tips_error">
<i></i>
<p v-text="errorMsg"></p>
</div>
How to fix this?
Just include this code to your css file
[v-cloak] { display:none; }
http://vuejs.org/api/#v-cloak
Usage example:
<div class="xpto" v-cloak>
Hello
</div>
This directive will remain on the element until the associated Vue
instance finishes compilation. Combined with CSS rules such as
[v-cloak] { display: none }, this directive can be used to hide
un-compiled mustache bindings until the Vue instance is ready.
http://vuejs.org/api/#v-cloak
I faced the same issue, and it was due to a conflicting display property on my div. To solve it, I used the !important flag on the [v-cloak] as:
[v-cloak] {
display: none !important;
}
.my-class {
display: table-cell;
}
Vue.js - 2.3.4, I added the v-cloak on the app container, adding this on the parent container, I find your not repeating the code keeping it DRY.
HTML:
<div id="app" v-cloak>
Anything inside gets the v-cloak
</div>
CSS:
[v-cloak] {
display:none;
}
Codepen Example:
https://codepen.io/Frontend/pen/RjoKQm
I fixed this problem by rewriting the CSS and adding a class in the CSS file
CSS:
[v-cloak] .v-cloak--hidden{
display: none;
}
HTML:
<div v-show="showErrorMsg" style="z-index:100" class="h5_tips tips_error v-cloak--hidden">
<i></i>
<p v-text="errorMsg"></p>
</div>
If you are using CDN to get Vue and using Bootstrap CSS then the reason might be you are loading the Bootstrap CSS in the bottom of the body tag, moving it back to the head tag worked for me. Make sure that you keep that vueJS file in the button as it is.
<HTML>
<head>
All link and script tag here
</head>
<body>
<div id='app' v-cloak>
{{ something }}
</div>
<script src="app.js"></script>
</body>
I have a scenario where I've got a search form and below, the results with a v-if block, waiting for submit.
I changed the v-if to v-show, that seemed to help. I tried the v-cloak--hidden class but didn't work either (v-cloak is already styled to display: none). What did work apparently was to set the data results container display style to none and then when submitting the form (in the processForm method), setting the display to block and show all the results.
processForm() {
// reset page number on new search
document.getElementById("data-container").style.display="block"
this.pageNumber = 1;
this.remoteRequest();
},
Without that change, on a full page refresh I could still see the moustaches coming up. Here the full HTML page, simplified.
<div id="app" v-cloak>
<main class="main-section">
<form method="POST" class="p-4 text-center" #submit.prevent="processForm">
<button type="submit" name="button" class="btn btn-primary">
Find
</button>
</form>
<!-- Results -->
<div id="data-container" class="container-fluid pt-2 pb-4" style="display:none">
<div class="row">
<div class="col">
<div id="recordsContainer" v-show="totalInScreen > 0">
<div class="card mt-5" v-for="(result, index) in results" :id="'itm-'+index" :key="result.id">
<div class="card-body">
<div class="row">
<div class="col">
<h2 class="doctor-name">{{ result.doct_name }}</h2>
<h2 class="doctor-bio">Bio</h2>
<p>{{result.doct_bio}}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
Unfortunately the above 2 answers didn't work for me as the problem was something else. Since this questions pops up #1 on Google, I thought I'd share my solution.
If you've defined a display css rule somewhere that's more specific, it will break the v-cloak functionality. However! Do not despair - simply copy this into your CSS file and it will work!
[v-cloak] .v-cloak--block {
display: block!important;
}
[v-cloak] .v-cloak--inline {
display: inline!important;
}
[v-cloak] .v-cloak--inlineBlock {
display: inline-block!important;
}
[v-cloak] .v-cloak--hidden {
display: none!important;
}
[v-cloak] .v-cloak--invisible {
visibility: hidden!important;
}
.v-cloak--block,
.v-cloak--inline,
.v-cloak--inlineBlock {
display: none!important;
}

Bootstrap 3 Carousel full screen flicker

I'm a beginner for web front-end design, using bootstrap to make a project prototype.
I want to do a product like this website
The features I want is
* expand carousel to full screen when visiting the website and then can scroll down to another div element.
I found this similar solution, but unfortunately it uses Carousel as the whole background.
To get the effect I want, I check the javascript src code and edit it.
modify this line (Shown on JSFIDDLE line 13 )
$('.carousel .item').css({'position': 'fixed', 'width': '100%', 'height': '100%'});
into this line (Shown on JSFIDDLE line 13 )
$('.carousel .item').css({'position': 'relative', 'width': $(window).outerWidth(), 'height': $(window).outerHeight()});
Yep, finally get the effect I want!! However, when the photo transition, a unexpected flicker appear, seems the photo is not at right location at first, then go to its right place immediately.
It's annoying when I see the content inside div below, like 1info or 2info.
here is the jsfiddle demo example for the issue.
I tried to use the solution like set z-index, but fail...
Can someone help me to solve this annoying problem? Thanks a lot!!
Here's a flicker-free version without any plugins:
HTML:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<div id="slide1" class="fill">
<div class=" carousel-caption">
<h1>1</h1>
</div>
</div>
</div>
<div class="item">
<div id="slide2" class="fill">
<div class=" carousel-caption" >
<h1>2</h1>
</div>
</div>
</div>
<div class="item">
<div id="slide3" class="fill">
<div class=" carousel-caption" >
<h1>3</h1>
</div>
</div>
</div>
</div>
</div>
CSS:
html, body {
height: 100%;
}
.carousel, .item, .active {
height: 100%;
}
.carousel-inner {
height: 100%;
}
.fill {
width: 100%;
height: 100%;
background-position: center;
background-size: cover;
}
#slide1 {
background-image: url('http://stylonica.com/wp-content/uploads/2014/03/Cute-Dog-Wallpaper.jpg');
}
#slide2 {
background-image: url('http://hdwallimg.com/wp-content/uploads/2014/02/White-Dog-Running-Wallpaper-HD.jpg');
}
#slide3 {
background-image: url('http://www.petfinder.com/wp-content/uploads/2012/11/122163343-conditioning-dog-loud-noises-632x475.jpg');
}
No additional javascript required, just make sure that the jquery and bootstrap.js files are linked in your page.

bootstrap place footer at bottom if content has smaller height then window

I want to place the footer at bottom of the window if the content of window has no scrollbars otherwise put the footer at the end of content
here is my html code
<div class="container-fluid">
<div class="header"></div>
<div class="con"></div>
<div class="footer">Copyright msg</div>
</div>
The effect you are looking for is known as a 'sticky footer', I believe -- where the footer will always appear pinned to the bottom of the page, even if the content is very short? You can find the solution here.
.footer {
position: fixed;
bottom: 0;
right: 0;
left: 0;
}