Resizable fixed footer with absolute elements within it - html

I want to make my fixed footer resizable on my 320px viewport, together with the absolute elements inside it.
I manage to get the footer div resizable, but the elements inside it doesn't seems to stick within the footer div when i resize the windows.
Note: I'm trying to create a footer with a background image. This image have some clickable areas which i created using the unordered list.
Here is my HTML Code:
<footer>
<ul>
<li>Shoot Me
</li>
<li>Facebook
</li>
<li>Tumblr
</li>
<li>Instagram
</li>
<li>E-mail
</li>
</ul>
</footer>
Here is my CSS Code:
footer{
z-index:21;
display:block;
position:fixed;
bottom:0;
left:0;
right:0;
padding:0;
width:1280px;
height: 426px;
max-width: 100%;
background:url(../images/layout/footer.png) no-repeat center bottom;
background-size: 100%;
margin:0 auto;
pointer-events:none;
}
footer ul li {
display: inline;
width: 14%;
}
footer ul li img {
border: none;
padding-left: 8px;
}
footer ul li a.shootme-link{
position:absolute;
bottom:200px;
left:1080px;
width: 151px;
height: 33px;
background:url(../images/layout/shootme.png) bottom;
pointer-events:auto;
/* Hide the text. */
display: inline-block;
overflow: hidden;
font-size: 0px;
}
footer ul li a.shootme-link:hover {
background-position: 0 0;
}
footer ul li a.facebook-link {
position:absolute;
width:33px;
height:29px;
bottom:40px;
left:970px;
pointer-events:auto;
/* Hide the text. */
display: inline-block;
overflow: hidden;
font-size: 0px;
}
footer ul li a.tumblr-link {
position:absolute;
width:33px;
height:29px;
bottom:40px;
left:980px;
pointer-events:auto;
/* Hide the text. */
display: inline-block;
overflow: hidden;
font-size: 0px;
}
footer ul li a.instagram-link {
position:absolute;
width:33px;
height:29px;
bottom:40px;
left:1030px;
pointer-events:auto;
/* Hide the text. */
display: inline-block;
overflow: hidden;
font-size: 0px;
}
footer ul li a.mail-link {
position:absolute;
width:33px;
height:29px;
bottom:40px;
left:1055px;
pointer-events:auto;
/* Hide the text. */
display: inline-block;
overflow: hidden;
font-size: 0px;
}
I'm still very much noob in CSS3 so i hope someone could enlighten me on this and pardon for my bad English. Hope it's not that confusing. Thanks
Here is the fiddle: http://jsfiddle.net/5JWG5/
Full screen fiddle: http://jsfiddle.net/5JWG5/embedded/result/

Ok, I Hope this help you, first:
it's easier using divs instead of a list, so we can achieve the location of the elements better.
<footer>
<div class="shootme-link">
Shoot Me
</div>
<div class="social">
<a class="facebook-link" href=" " target="_blank" >Facebook</a>
Tumblr
Instagram
E-mail
</div>
</footer>
as you can see, i also reduce the number of classes, instead using one for each element, now i'm using just one name it "social", this will be a Div box that will nest the link elements.
Then, we will point to the links inside that div to give them size and we will float all to the left. using display: inline-block and text-align: left; (you could also use display: block; and float: left; but the you should give them a margin)
this is the new CSS
footer{
z-index:21;
display:block;
position: absolute;
margin: 0 auto;
bottom:0;
left: 0;
right: 0;
width:1280px;
height: 426px;
max-width: 100%;
background:url("http://jennisa.com/images/layout/footer.png") no-repeat right bottom;
background-size: cover;
pointer-events:none;
}
footer > .shootme-link {
display: block;
position:absolute;
bottom:200px;
right: 50px;
width: 151px;
height: 33px;
background:url("http://jennisa.com/images/layout/shootme.png") bottom;
pointer-events:auto;
/* Hide the text. */
text-indent: -999px;
overflow: hidden;
}
footer > .social {
position: absolute;
width: 163px;
height: 32px;
bottom: 46px;
right: 163px;
pointer-events: auto;
}
footer > .social > a {
background-color: blue;
width:33px;
height:29px;
display: inline-block;
text-align: left;
pointer-events:auto;
/* Hide the text. */
text-indent: -999px;
overflow: hidden;
}
there is a jsfiddle
for the background size I use the attribute cover instead 100% because this will kep the proportions of the image to cover all the div and also i positioned the image to the right, because is there where the elements are (the elements also are positioned absolute since the right.
you just delete background-color: blue; from the links (I used it to point the changes visually)
Hope this help you.

I'm not shure of what you're trying to do, i speak spanish, if that language works for you, you could explain better in it.
anyway, i think you could use position: relative; instead of position:absolute;.
"inline-block" has text capabilities, so you can use text-align: center; or use display:block; and float everything to the left.
but i don't see the point of "float" your elements if give them an absolute position.. may be you could use jsfiddle to explain your point better with an example.
is not necessary to use max-width: 100%;you just put the width at 100% of the size and declare the minimun width size, for example "320px" and the div will not be smaller than this size.
Hope this help you :)

Related

how to make element of navbar always visible on resize?

I have a navbar that contains a div, i need to do it like instagram.com that when i resize the window; the inside element stays always visible.
Is there a certain strategy in CSS to do the same thing?
CSS:
.navbar {
position: fixed;
background-color: #039D6E;
width:100%;
height: 55px;
white-space: nowrap;
}
.subNav{ /* Inside Div of the navbar that always need to be visible */
height:55px;
width:auto;
display: inline-block;
position: relative;
left:25%;
white-space:nowrap;
padding: 12px;
}
Just give .subNav a fixed width, for example width: 150px;.
See test fiddle below:
.navbar {
position: fixed;
background-color: #039D6E;
width:100%;
height: 55px;
white-space: nowrap;
padding: 0px;
margin: 0px;
}
.subNav{ /* Inside Div of the navbar that always need to be visible */
height: 51px;
width: 150px;
resize:none;
border: 2px solid red;
position: relative;
left:25%;
white-space:nowrap;
//padding: 12px;
margin: 0px;
}
<div class="navbar">
<div class="subNav">
</div>
</div>

Getting absolutely positioned elements to flow with the rest of a layout

I have a slideshow which works by absolutely positioning images one on top of the other and then changing the z-index of whatever slide I want to appear. The problem is I'd like to move it to the center and have the "prev" link and the "next" link on either side of the slideshow.
I've been trying to create a container with relative positioning around the absolutely positioned items and can get the slideshow to move around, but the next link doesn't show up on the other side of the slideshow (and I hope not to use hacks with margins to mess up the flow of the page).
My goal is to be able to treat the slideshow box just like any other box that flows with the rest of the page. Is there a way to do that?
my html
<a id="prevLink" href="#">Prev</a>
<div class="container">
<ul id="slideshow">
<li class="current">First</li>
<li>Second</li>
<li>Third</li>
</ul>
</div>
<a id="nextLink" href="#">Next</a>
my css:
.container {
position: relative;
}
#slideshow {
position: relative;
list-style-type: none;
}
.current {
z-index: 99;
}
#slideshow li {
position: absolute;
width: 5em;
height: 5em;
background-color: #333;
font-size: 3em;
color: #fff;
}
Link to the slideshow: http://codepen.io/KenjiCrosland/pen/QyqVaz
A couple changes you need:
Set the #container to display:inline-block and give it a width so that it stays inline.
remove the default padding from #slideshow.
Try this CSS:
.container {
position: relative;
width:15em;
display:inline-block;
}
#slideshow {
position: relative;
list-style-type: none;
padding:0;
}
.current {
z-index: 99;
}
#slideshow li {
position: absolute;
width: 5em;
height: 5em;
background-color: #333;
font-size: 3em;
color: #fff;
}
Here's a fork of your Pen.
You need to give a width and height to .container and center it.
Set in absolute prev and next, add some padding to .container so it has room for buttons. http://codepen.io/anon/pen/MKERWZ
.container {
position: relative;
width: 15em;/* 3x5em of lis */
height:15em;
padding: 0 4em;/* room on left/right for buttons */
margin: auto;
background: gray;/* demo purpose, lets see where it stands */
}
#slideshow {
list-style-type: none;
margin:0 ;
padding:0;
}
.current {
z-index: 99;
}
#slideshow li {
position: absolute;
width: 5em;
height: 5em;
background-color: #333;
font-size: 3em;
color: #fff;
}
#prevLink,
#nextLink {
position:absolute;
top:50%;
line-height:0;/* to set in center without translate() */
}
#prevLink {left:0.75em;
}
#nextLink {right:0.75em;
}

override parent overflow:hidden with child overflow:visible

I have a header which is the parent of the nav and logo. I have set the parent to overflow:hidden so I was able to add margin-top to the nav to get it to sit at the bottom. However it clips the logo div as well. I was trying follow this question...Overriding overflow: hidden
so tried to set the logo to overflow:visible but that hasn't worked either. I am not sure of any other solution other than the logo not being in the parent container.
Here is my code
CSS:
.container {
width: 960px;
margin:0 auto;
background-color: blue;
}
header {
height: 100px;
background-color: #001D5D;
position: relative;
overflow: hidden;
}
#logo {
height:100px;
width:100px;
z-index:10;
top:0px;
position: absolute;
overflow: visible;
}
nav {
background-color:#1CCEAE;
margin-top:63px;
}
nav ul {
width:100%;
line-height: 37px;
text-align:right;
background-color:#1CCEAE;
}
ul li {
display: inline-block;
margin-right: 20px;
}
ul li a {
text-decoration: none;
font-size: 1em;
color:white;
}
Here is a fiddle
http://jsfiddle.net/XS3Zs/
remove width:100% to ul or reset padding to 0 to ul.
<ul> doesn't really need width:100%; since it is a block element, it will use all width avalaible., width set to 100% may be too much. Borders, margin and padding will not be estimated.
The UL element has by default padding-left:40px; so if you set that to 0 it will be fine.
I updated your [FIDDLE]

Positioning inside header and divisions

Since the code is long I have fiddle for it
<header>
<div>
</div>
</header>
FIDDLE: http://jsfiddle.net/9zWm9/34/
Q: Can you please tell why my list items are not aligning to the navigation inside header-box.
Requirement: I want my list items to be exactly in center of header-box with the line-height of 3em.
Thanks in advance.
To align your ul horizontally you need to clear the float, I've done that using a br element with class="clear"
.clear { clear:both; }
and to position the s vertically I used position:relative; with top:15%;
check out this fiddle
And here's another way if you don't want to set position on the li elements, this way you should set a line-height on your ul element (instead of height).
check out this fiddle
Remove the position:relative for the .header-box and add overflow: hidden. Remove the height specified for .header-box, header nav and header nav ul and add padding to header nav ul
Check this fiddle
CSS changes
.header-box {
/* top: 40px; */
width:100%;
/* height: 81px; */
/* position: relative; */
overflow:hidden;
}
header nav{
border: 1px solid black;
/* height: 81px; */
}
header nav ul{
width:100%;
/* height: 81px; */
margin:0px auto;
/* padding:0px; */
padding:15px 0px;
text-align:center;
}
Yes, problem is the line-height. A possible solution is changing the line-height to 1:
font: 18px Verdana;
display: inline-block;
list-style-type: none;
text-align:center;
line-height: 1;
border: 1px solid red;
http://jsfiddle.net/9zWm9/35/
Set your following class to "line-height: 1em;"
header nav ul li {
border: 1px solid #FF0000;
display: inline-block;
font: 18px Verdana;
list-style-type: none;
text-align: center;
line-height: 1em;
}

<a> works for only a small part of an image?

The question doesn't describe this pretty well.
So I got three small images that are suppose to change on hover and work as a link, but it ''detects'' the hover only in a small part of the image. If I drag my mouse to the bottom of the image link, it's not even clickable, so the link only works in the top part of the image.
See for yourself:
http://jsfiddle.net/M3LC9/ (JSFiddle doesn't like pictures..)
<div class="kielet">
<nav>
<!--Englanti-->
<img class="icon" src="iconit/en.gif" title="in english" onmouseover="this.src='iconit/en_hover.gif'" onmouseout= "this.src='iconit/en.gif'">
<!--Ruotsi-->
<img class="icon" src="iconit/swe.gif" title="på svenska" onmouseover="this.src='iconit/swe_hover.gif'" onmouseout="this.src='iconit/swe.gif'">
<!--Venäjä-->
<img class="icon" src="iconit/ru.gif" title="По русски" onmouseover="this.src='iconit/ru_hover.gif'" onmouseout="this.src='iconit/ru.gif'">
</div>
.kielet {
top:0px;
width:100%;
background: black;
right: 0px;
margin-bottom:0px;
padding:0px;
}
.kielet nav {
right: 0px;
margin-right: 0px;
text-align: right;
}
.icon {
width: 50px;
height: 100%;
right: 0px;
margin: 20px;
margin-top:0px;
margin-bottom:0px;
display:inline;
padding: 0px;
}
You currently have your images set to display as inline. This will make them adhere to any line-height defaults a browser may have set on your a element, keeping your a element at a smaller height. This can be visualised in Chrome's Element Inspector:
To change this, simply set the display on your a elements to inline-block:
a {
display: inline-block;
}
JSFiddle demo.
Note that you may want to be a bit more specific with your a selector by specifying .kielet nav a, for instance, or giving your a elements their own class identifier.
Try changing the display property to display:inline-block
.icon {
width: 50px;
height: 100%;
right: 0px;
margin: 20px;
margin-top:0px;
margin-bottom:0px;
display:inline-block; <----
padding: 0px;
}
JSFiddle
Usually you don't implement your hover-state with javascript and <img />
You can easily do this with CSS.
HTML
<div class="kielet">
<nav>
<!--Englanti-->
<!--Ruotsi-->
<!--Venäjä-->
</nav>
</div>
CSS
.kielet {
background: black;
padding: 5px;
text-align: center;
}
a.icon {
display: inline-block;
width: 16px;
heiht: 16px;
line-height: 16px;
}
a.icon_ru { background: url(http://placehold.it/16x16/ffc) center no-repeat; }
a.icon_ru:hover { background: url(http://placehold.it/16x16/ff0) center no-repeat; }
a.icon_en { background: url(http://placehold.it/16x16/cff) center no-repeat; }
a.icon_en:hover { background: url(http://placehold.it/16x16/0ff) center no-repeat; }
a.icon_swe { background: url(http://placehold.it/16x16/fcf) center no-repeat; }
a.icon_swe:hover { background: url(http://placehold.it/16x16/f0f) center no-repeat; }
jsFiddle