Using slick: http://kenwheeler.github.io/slick/
HTML
<div class="carsoule" style="overflow:hidden; width: 300px; height: 200px; margin: 0 auto; background:red">
<div>
<img src="http://theheightsanimalhospital.com/clients/15389/images/playful-kitten-6683.jpg" width="250">
</div>
<div>
<img src="http://theheightsanimalhospital.com/clients/15389/images/playful-kitten-6683.jpg" width="250">
</div>
</div>
CSS
.slick-prev, .slick-next {
height: 55px;
width: 55px;
}
.slick-prev {
left: -80px;
/*plan to add button image*/
}
.slick-next {
right: -80px;
/*plan to add button image*/
}
Jsfiddle Demo
Tried to override, but the prev and next buttons stay stuck inside the carousel. Wanted to replace the css with button images and the buttons should be outside the carousel, just like the example on slick website. Couldn't figure where I went wrong.
Help appreciated!
UPDATE : $('.carsoule').slickNext(); won't work anymore.
Use $('.carsoule').slick("slickNext"); instead.
https://github.com/kenwheeler/slick/issues/1613
Looking at the css that this plugin uses, I noticed the parent has overflow:hidden applied to it, so your arrows wont show beyond the parents container.
You can mess with adding a extra overflow !important rule to the container, however, I've looked over at some methods that you can use to trigger next/prev slide, and turns out that you can call on your carousel to change slide, when clicked on a certain class/id outside of the carousel container.
So basically, after your carousel(or anywhere on the page if it helps you out), add two div/button/a/whatever tags, and add either a class or id to call upon the slider to change its slide using: slickNext() or slickPrev()
You can wrap everything in a master container, your carousel and those two extra tags and style them the way you want.
Check out the demo here, and the extra js/markup used bellow:
<div class='next-button-slick'>
next please
</div>
<div class='prev-button-slick'>
prev please
</div>
$('.next-button-slick').click(function(){
$('.carsoule').slickNext();
});
$('.prev-button-slick').click(function(){
$('.carsoule').slickPrev();
});
UPDATE 2
If you want to keep your markup, and not add any extra stuff, you can either remove the inline overflow: hidden rule from the container, or via css with overflow: visible !important, and set those 2 arrows to position absolute, and work you way from there.
Check out the demo here and the css bellow:
/*extra stuff*/
.carsoule{
overflow: visible !important;
}
.slick-prev, .slick-next {
position: absolute;
background: red;
}
<div class='next-button-slick'>
next please
</div>
<div class='prev-button-slick'>
prev please
</div>
$('.next-button-slick').click(function(){
$('#portfolio-carousel').slick("slickNext");
});
$('.prev-button-slick').click(function(){
$('#portfolio-carousel').slick("slickPrev");
});
This should solve your issue,
CSS
body {
background: #d7d7d7;
}
.carsoule {
background: yellow;
margin: 0 auto;
overflow: visible;
width: 250px;
}
.slick-prev,
.slick-next {
height: 55px;
width: 55px;
}
.slick-prev {
left: -80px;
/*plan to add button image*/
}
.slick-next {
right: -80px;
/*plan to add button image*/
}
HTML
<div class="carsoule">
<div>
<img src="http://theheightsanimalhospital.com/clients/15389/images/playful-kitten-6683.jpg" width="250" />
</div>
<div>
<img src="http://theheightsanimalhospital.com/clients/15389/images/playful-kitten-6683.jpg" width="250" />
</div>
</div>
The carsoule had overflow:hidden, so if you positioned it outside it was hidden.
The problem is the hover. Just add the block of code below to it and you'll be just fine.
.slick-next:hover,
.slick-prev:hover {
background-color: red;
color: white;
}
See working example here
You missed out the important slick-theme.css http://kenwheeler.github.io/slick/slick/slick-theme.css. I added this file and meddled with your codes and came up with this solution:
HTML
Re-styling your wrapper to include .slider class with proper margins:
class="carsoule slider"
Modified CSS
.slick-prev:before, .slick-next:before {
color:red;
}
.slick-prev, .slick-next {
height: 55px;
width: 55px;
}
.slick-prev {
left: -80px;
/plan to add button image/
}
.slick-next{
right: -80px;
/plan to add button image/
}
.slider {
margin:0 80px 0 80px;
width: auto;
}
Related
I'd like to change the background image of the body (or my section) on link hover as in this example:
http://www.passion-pictures.com/paris/directors/
Is there any way to do it without using JS.
I only know how to code HTML/CSS
EDIT :
When I Hover on the first link (Michelle) it changes the background of my section as expected.
But when I hover on the second link (Franck) the top of my second link background begins under my first link. So the top of my default background is still visible.
My links are displayed vertically
It is possible but there will be too much HTML code and CSS workarounds.
if you still want in CSS only then refer this code - change css background on hover
HTML code
<div class=container>
<div class="link">
bg1
<div class=background></div>
bg2
<div class=background><div>
</div>
</div>
CSS Code
div.link > a {
displya: inline-block !important;
position: relative !important;
z-index: 5;
}
.bg1:hover + .background {
background: red;
}
.bg2:hover + .background {
background: green;
}
.background {
background: transparent;
position: absolute;
width:100%;
height: 100%;
top:0;
left: 0;
}
This will give you an idea of implementation but I'll suggest you go with JS that is a much better way of doing it.
Hope this might help you
HTML
<div class="container">
bg1
</div>
CSS
.bg1:hover::after {
content: "";
position: fixed;
top: 0;
left: 0;
background: red;
width: 100%;
height: 100%;
z-index: -1; /* index would get changed based on your need */
}
<div style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 999999999; opacity: 0; cursor: pointer;"></div>
I'm trying to remove this entire thing with jQuery but i don't know how to actually refer to the style or div, i don't really know what i should call it.
It doesn`t have a dot between < and div, i had to do that so the site would show it.
give id or class to that div and than you can hide that div with jQuery
example:
<div id="block" class="blabla">...</div>
<script>$("#block").hide(); // or (".blabla").hide(); </script>
For removing:
You can do it in css:(or add to the div's style)
div{
display:none
}
Div's style:
<div style="display:none;..."></div>
I am trying to get a sidebar push navigation that looks like this. I do actually have content in between my center element div. My html looks like:
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×
</a>
Home
About
Projects
Hire Me
</div>
<div id = "main">
<span style="font-size:50px;cursor:pointer" onclick="openNav()" id="btnMenu">☰</span>
<div class = "centerElement">
</div>
</div>
I believe its probably because my centerElement class that is not allowing its content to be pushed. If that is true my btnMenu will also have to be changed.
css code here:
.centerElement {
position: absolute;
top: 50%;
left: 50%;
width: 600px;
height: 600px;
margin: -300px 0 0 -300px;
}
#main {
transition: margin-right .5s;
padding: 16px;
}
#btnMenu {
position: absolute;
top: 72px;
right: 128px;
font-size: 18px;
}
javascript is
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginRight = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginRight= "0";
}
I also tried my first fiddle but for some reason my navbar doesn't even open in it. Didn't really care to put the effort to find out why but if this helps here it is.
I got your fiddle working in a code pen, if I understand your question you want to push the content to the side when opening the side nav. I changed a few css properties to achieve this.
you have your centerElement which has position: absolute; this wont allow it to adjust to the side nav when it opens.
same with your btnMenu icon
I created a div around your btnMenu and added
.menuIcon {
text-align: right;
}
which places it on the right side like you had it.
also I removed your btnMenu styles
I also changed your .centerElement class to
.centerElement {
width: 45%;
margin: auto;
}
this centers the content and adjusts when the nav opens.
You may have to play with some other margins and padding to get things to line up, but I think this is what your going for.
https://codepen.io/anon/pen/qjORpO
After trying every possible variation of position: relative/absolute/etc and negative margins, I'm wondering if someone can tell me how to get the two green bars to overlay the header image - at top and bottom - at http://itlaunchpad.patienceandfortitude.com/iphone-cant-get-your-email/.
*Note that the main header has to remain an img and not become a background property due to the way WordPress' custom image header handles responsiveness.
Many thanks!
Absolutely position the two bars within the common ancestor element. For example:
<header>
<nav>Foobar</nav>
<img src="http://placekitten.com/640/200" />
<nav>Foobar2</nav>
</header>
And with the following CSS:
header {
position: relative
}
nav:nth-of-type(1) {
top: 0
}
nav:nth-of-type(2) {
bottom: 0
}
nav {
background-color: rgba(0,255,0,.25);
box-sizing: border-box;
position: absolute;
width: 100%;
}
Which gives you the following: http://jsfiddle.net/M3jyV/
Try this css
and make the inline css to external css its for your reference (inline css).
bootstrap.css line 5416
#masthead.container {
padding: 0;
position: relative;
width: 1198px;
}
app.css line 13
#banner {
position: absolute;
}
bootstrap.css line 3779
.navbar {
color: #777777;
overflow: visible;
position: absolute;
width: 100%;
}
<div class="container" style="width:100%">
<header style="margin-top: -40px;" class="navbar" role="banner">
see image:
you can use CSS z-index Property
for Example- http://brenelz.com/blog/squish-the-internet-explorer-z-index-bug/
DEMO - http://jsfiddle.net/xY5Re/75/
I found a lot of questions on stack overflow about getting rid of white space, but I can't seem to figure out how to put it in.
I have a bottom navigation on my site that floats with the page, but if the window is small, the bottom part of the page gets covered up. I would like to insert some white space at the bottom, so when the window is smaller than the length of the page you can still read it.
I've tried adding:
margin-bottom: 50px;
padding-bottom: 50px;
to the div containing the top page content, but it doesn't work.
Is there something I am missing? Here's a demonstration: http://www.writingprompts.net/name-generator/
#left, #right {
margin-bottom: 90px;
}
or
#top_section > div {
margin-bottom: 90px;
}
It doesn't work on #top_section because you use absolutes and therefore the content actually over extends the div itself, but trust me, either of those two css' i gave you WILL work
Simply add the following rule:
#top_section {
overflow: hidden;
padding-bottom: 90px;
}
This will make #top_section be as big as the floating content inside it.
http://jsfiddle.net/rlemon/fSYmu/ This is a simplified example, having no idea what your layout looks like (I am not going to assume the demonstration is yours... unless you revise and tell me it is) i'll show you how I would do this
HTML
<div class="container"> <!-- main page wrapper -->
<div class="content"> <!-- main content wrapper, backgrounds apply here -->
<div class="inner-content"> <!-- content inner, where your content goes! -->
content
</div>
</div>
<div class="footer">footer</div> <!-- footer -->
</div>
CSS
html,body,.container {
height: 100%; margin: 0; padding: 0; // I am important so the page knows what 100% height is.
}
.content {
height: 100%; // see above... i need to cascade down.
background-color: green;
}
.content-inner {
padding-bottom: 100px; // offset for the footer.
}
.footer {
width: 100%;
position: absolute; // stick me to the bottom.
bottom: 0;
height: 100px;
background-color: red;
}
enjoy!
You need to use fixed position in CSS to achieve this.
HTML:
<div id="top-section">
Insert content here...
</div>
<div id="bottom-nav">
<div id="content">
Bottom content...
</div>
</div>
CSS:
#bottom-nav {
bottom: 0;
position: fixed;
width: 100%;
}
#content {
margin: 0 auto;
width: 960px;
}