Image next to li row images - html

So, this might sound basic for some of you guys. But i just haven't been able to figure it out.
So i have this CSS and this HTML Code:
<style type="text/css">
ul.ppt {
position: relative;
}
.ppt li {
position: absolute;
left:0;
right:0;
}
.ppt img {
margin-left: 5px;
}
</style>
<center>
<ul class="ppt">
<li>
<img src="#">
<img src="#">
</li>
</ul>
With this code i will have 2 pictures next to each other in the center.
Now i would like to add 2 more pictures, those 2 just can't be in "lo" nor "li". But the pictures will have to be on the same row, one of them will be at the start and the other one will be at the end, how can i do this?
(Click here for a picture explanation)
Thanks in advance.

Check http://jsfiddle.net/AvqEB/1/
ul.ppt {
position: relative;
list-style:none;
display:inline-block;
padding:0;
margin:0
}
.outerimg { display:inline-block; margin-left: 5px;}
.ppt li {
display:inline-block;
}
.ppt img {
margin-left: 5px;
}
and html
<img class="outerimg" src="http://s.imwx.com//img/common/WinApp_Zoom_155x114.jpg" />
<ul class="ppt">
<li>
<img src="http://s.imwx.com//img/common/WinApp_Zoom_155x114.jpg">
<img src="http://s.imwx.com//img/common/WinApp_Zoom_155x114.jpg">
</li>
</ul>
<img class="outerimg" src="http://s.imwx.com//img/common/WinApp_Zoom_155x114.jpg" />

You can do this by floating things to the left. Here is a jsfiddle demo: http://jsfiddle.net/6L7x9/1/
On an aside, I find using DIV with a centered class far preferable to using the CENTER tag.
<style type="text/css">
ul.ppt {
position: relative;
padding:0px;
margin:0px;
}
.ppt li {
padding:0px;
margin:0px 5px;
list-style-type: none;
float: left;
}
.leftfloat { float: left; }
.inlineimage {
margin:0px 0px 0px 5px;
border:0px;
}
</style>
<center>
<img src="#" class="leftfloat inlineimage" />
<ul class="ppt leftfloat">
<li>
<img src="#" class="inlineimage">
<img src="#" class="inlineimage">
</li>
</ul>
<img src="#" class="leftfloat inlineimage" />
One does wonder why the bounding images must be outside the UL...
UPDATE POST OP COMMENT
Ok, I've taken your sample, dropped it into JSFiddle, and modified it so that back & forward are on either side of the "slideshow" image (http://jsfiddle.net/SFvGk/). One immediate issue is the varying width of the slideshow frame, which causes the "next" button to jump around. You could mitigate that by setting a fixed with for the UL, and then accepting empty space when narrower images are displayed.
Modifications:
Add class "payitforward" to the next/prev buttons.
Add style "display:inline-block" to UL and set margin/padding to 0 for UL and LI.
Add to top of script:
var $slideContainer = $("ul.ppt");
$slideContainer.width(cur.width())
Add to end of "forward" function:
$slideContainer.width(cur.width())
Comments:
You might look into events on the fadeIn/fadeOut functions to possibly smooth out movement of the "Next" button on the right, or just fix the width of the slideshow container so the "Next" button never moves.
Definitely look into requestAnimationFrame to replace "setInterval". Here is one resource: http://creativejs.com/resources/requestanimationframe/.

Use :after and :before.
li{height:20px; width:20px; margin:10px; background:red; display:inline-block; position:relative;}
li:before, li:after{content:" "; position:absolute; height:20px; width:20px;}
li:last-child:after{background:blue; right:-25px;}
li:first-child:before{left:-25px; background:green;}
Fiddle here.

Related

HTML positioning with more items

I'm sort of new to HTML and currently, I am creating a custom home page for myself containing links to site I often visit.
When I hover over a picture it expands to show more specific links (i.e. subreddits).
However, the problem is that the "sub-link-icons" are not properly aligned with the expanding DIV It will show in front of the bigger picture when hovering over it.
What I am trying to do is have the sub-link-icons to be in sync with the expanding div.*
HTML:
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<title>Homepage</title>
</head>
<body>
<div class="submenu" id="steam"><img src="steam.png"></div>
<div class="submenu" id="reddit">
<img src="reddit.png"/>
<ul>
<li><img src="reddit.png"/></li>
<li><img src="reddit.png"/></li>
<li><img src="reddit.png"/></li>
</ul>
</div>
<div class="submenu" id="youtube"><img src="youtube.png"/></div>
</body>
</html>
CSS:
body {
background-color: #330000;
color: white;
}
div img {
width:256px;
height:256px;
border-radius:5px;
}
li img {
width:75px;
height:75px;
border-radius:15px;
}
#youtube:hover {
border: #E6E6E6 solid 4px;
background-color: #E6E6E6;
}
#steam:hover {
border: #12151A solid 4px;
background-color: #12151A;
}
#g2a:hover {
border: #0F1F2E solid 4px;
background-color: #0F1F2E;
}
#reddit:hover {
border: #999999 solid 4px;
background-color: #999999;
}
ul{
position:absolute;
list-style-type: none;
display:none;
margin-left: 125px;
}
.submenu {
border-radius: 5px;
position:relative;
display: inline-block;
margin-left: 0px;
width:256px;
height:256px;
border:4px solid #330000;
text-align:center;
margin-left:5px;
margin-top:5px;
transition: width 1s;
z-index:0;
}
.submenu img {
float:left;
}
.submenu:hover {
width:350px;
transition: width 1s;
}
.submenu:hover img {
float:left;
z-index:2;
}
.submenu ul {
position: absolute;
}
.submenu:hover ul {
display:inline-block;
float:right;
margin-top:-10px;
margin-left:-45px;
position:absolute;
z-index: 1;
}
.submenu:hover ul li img {
float:left;
margin-left: -30px;
margin-top: 12.5px;
}
I've tried searching the web for help but couldn't quite manage it.
JSFIDDLE
Lets go through this step by step.
First issue: On hover, "sub-icon-links" are layered over your big pictures, instead of under it.
This IS fixable with z-index, but first you have to understand how z-index works.
Note: z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).
With z-index you can layer elements that are in the same HTML layer. Because it didn't work I assume you've tried to apply z-index on the sub-menu-links. This wouldn't work because the big picture is not on the same layer as them. If we take a look at your HTML structure you'll see:
<div class="submenu" id="reddit">
<img src="http://www.workatplay.com/files/styles/fpo_medium/public/article/logo/Reddit%20Small.jpg?itok=dclAuuiP"/>
<ul>
<li><img src="http://www.workatplay.com/files/styles/fpo_medium/public/article/logo/Reddit%20Small.jpg?itok=dclAuuiP"/></li>
<li><img src="http://www.workatplay.com/files/styles/fpo_medium/public/article/logo/Reddit%20Small.jpg?itok=dclAuuiP"/></li>
<li><img src="http://www.workatplay.com/files/styles/fpo_medium/public/article/logo/Reddit%20Small.jpg?itok=dclAuuiP"/></li>
</ul>
</div>
To use z-index in this case, you have to see at which points the images or their containers are on the same layer.
Your big image is contained within an anchor tag (a)
Your small images are contained within list items
These list items are contained within an unordered list
This unordered list and the anchor tag are on the same layer. Applying z-index to one of these will fix this issue.
Note: This works different when using things like "position: absolute" and "position: fixed" or any other attribute that changes the position of the element in the HTML stack.
JSFiddle: https://jsfiddle.net/eehdo8wa/5/
What I did:
Added "z-index: -1;" to ".submenu ul"
Removed "z-index: 1;" from ".submenu:hover ul"
Second issue: On hover, the "sub-icon-links" should expand at the same rate as the div expands
So, doing this should be very simple now the pictures are layered under the big picture correctly. Basically, when you think about it, all you should have to do is make the pictures stick to the right side of its parent, so when it expands, the pictures stick to the right side and slide along, taking them into the view.
JSFiddle: https://jsfiddle.net/eehdo8wa/6/
What I did:
I redid some of the CSS to make it so everything is already in the right position before sliding into the view. This is essentially what you want in these cases. In your original fiddle you had a LOT of styling on the hover portions, changing all kinds of styling and spacings, but was it really needed? In the end, no. Now it's all in position behind the big image, ready to slide right into the view.

Image in link is moving the link location

I'm making a basic navigation bar that consists of inline links all containing text and some also containing images. When an image is within the link, it moves the link element background (it does not move the link text apparently). The background moves more if the image is set to a larger size. I want all the elements to be exactly lined up.
Here is an image of the problem
Here is the relevant HTML:
<!--navigation bar-->
<div id="nav">
<a class="navLinks" href="">Resume</a>
<a class="navLinks" href="mylinkedinprofileURL">
<img class="logo" id="logo_linkedin" src="images/logoLinkedin.png">LinkedIn</a>
<a class="navLinks" href="wordpress">
<img class="logo" id="logo_wordpress" src="images/logoWordpress.png">WordPress</a>
<a class="navLinks" href="travels">Travels</a>
</div>
And here is the relevant CSS:
#nav {
position: relative;
top: 10px;
text-align: center;
}
.navLinks {
border-radius: 3px;
text-decoration: none;
color:white;
text-align: center;
width:110px;
height:20px;
padding:15px;
background-color: #353841;
display:inline-block;
}
.logo {
height:20px;
position:relative;
right:10px;
}
I'm very new to web development, so if there is a much better or more elegant way to be doing this, please let me know!
Add vertical-align:top to the tabs.
.navLinks {
vertical-align:top;
}
See DEMO here.

Footer using HTML & CSS-

I'm creating a website and I have a footer at the bottom of the page. I want to place the text at some above from the current position, without increasing the height of the footer. Can someone tell me how to do this please?
Current HTML is
<div class="footer">
<ul id="footer">
<li> <img src="Images/facebook.png" /> <img src="Images/twitter.png" /> </li>
<li> Jewllery</li>
<li> ADDRESS </li>
<li> TEL PHONE</li>
</ul> </div>
and the current css is
.footer
{
text-align:centre;
background-color:#C8C8C8;
color:#000000;
}
#footer li
{
display:inline-block;
padding-right:3em;
}
You can set a negative margin-top like this:
.footer {
margin-top: -3em;
}
Edit:
What he tried to do is move the text inside the footer up, not the footer itself.
So you have to give the li-element a negative margin-top:
#footer li {
display:inline-block;
vertical-align:middle;
margin-top: -50px;
}
One thing you could try
.footer {
margin-top: -1em;
}
From what you said im taking it as (move the text in the footer up, without actually effecting the footer)
set the child footers margin as a negative.
#footer{
margin-top:-20px;
}

Beginner : Help me replace a background image logo with a clickable one [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm not really good with CSS and html when the layout is complicated. I can quick fix things, but I have no real knowledge.
I'm trying to adapt this demo : http://demo.marcofolio.net/bgimg_slideshow/ for my website.
Problem: the logo is a background image for a div and not a link.
I'm not good enough to see how i could change it without defacing the layout.
Could you help me either by providing the fix (if it doesn't take you more than 5 minutes) or by giving me hints or links so i could figure it out myself?
Edit : here's a jsfiddle with minimum code
And here are the files :
html :
<div id="header">
<div id="headerimgs">
<div id="headerimg1" class="headerimg"></div>
<div id="headerimg2" class="headerimg"></div>
</div>
<div id="nav-outer">
<div id="navigation">
<div id="menu">
<ul>
<li>Marcofolio</li>
<li>Twitter</li>
<li>RSS</li>
<li>jQuery</li>
<li>CSS</li>
<li>Advertisements</li>
</ul>
</div>
</div>
</div>
</div>
Css :
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input{margin:0; padding:0;}
#header { height:600px; }
.headerimg { background-position: center top; background-repeat: no-repeat; width:100%; height:600px; position:absolute; }
#nav-outer { height:110px; padding-top:11px; position:relative; top:24px; background-image:url("http://demo.marcofolio.net/bgimg_slideshow/images/headerbg.png"); }
#navigation { height:100px; width:960px; margin:0 auto; background-image:url("http://demo.marcofolio.net/bgimg_slideshow/images/logo.png"); background-position:top left; background-repeat:no-repeat; }
#menu { position:relative; top:85px; }
#menu ul { list-style:none; }
#menu ul li { display:inline; font-variant:small-caps; font-size:12px; }
#menu ul li a { color:white; text-decoration:none; font-weight:bold; padding-right:20px; }
#menu ul li a:hover { text-decoration:underline; }
You should add
<div id="logo">
<a href="#">
<img src="images/logo.png" alt="" />
</a>
</div>
to <div id="#navigation">, right before <div id="search">
Then:
1) you should float the logo to the left
#logo{
float: left;
}
2) remove top: 85px; from #menu and add clear: both;
3) remove background-image: url("../images/logo.png"); from #navigation
This way, you have clickable image logo. :)
Explanation:
You float the logo to the left because #search is floated to right
You remove top: 85px; because that was compensation for empty space which is now filled with image, and add clear: both because it clears the floats and positions the menu back in place
Here is how I did it.
First, Remove the background image from your #navigation div.
Then add the following as a first child of the #navigation.
<a href="/" style="
height: 80px;
width: 500px;
background-image: url('http://demo.marcofolio.net/bgimg_slideshow/images/logo.png');
background-position: top left;
background-repeat: no-repeat;
display: inline-block;
position: absolute;
" alt="Image Description"></a>
So your Navigation div should look like this:
<!-- Remove all background attributes from #navigation in the CSS -->
<div id="navigation">
<!-- Below is the new line!, makes your logo clickable! -->
<a id="logo" href="" style="height: 80px; width: 500px; background-image: url('http://demo.marcofolio.net/bgimg_slideshow/images/logo.png'); background-position: top left; background-repeat: no-repeat;display: inline-block; position: absolute;"></a>
<!-- Everything else below stays the same!... -->
<div id="search">
<form>
<input type="text" id="searchtxt">
<input type="submit" value="search" id="searchbtn">
</form>
</div>
<div id="menu">
<ul>
<li>Marcofolio</li>
<li>Twitter</li>
<li>RSS</li>
<li>jQuery</li>
<li>CSS</li>
<li>Advertisements
</li></ul>
</div>
</div>
Basically, you make a <a href> which has a background image (all a href's are clickable). When you assign a background image to a <a href>, you have to set the display:block for it to be rendered as a block level element. In this case, we position it absolutely to knock it out of the document flow and keep it from disturbing other elements.
There are better ways to do this, but it would probably require re-writing some of your code (Which is not that difficult, but does require an amateur skill level of HTML & CSS).
Hope this helps!
I did some live edits on the link you provided. I think this is what you want to achieve.
Here is a Demo, based on your fiddle.
HTML
<div id="navigation">
<h1 id="logo">My Website!<br />
<span>loving jQuery and CSS</span>
</h1>
...
CSS
#navigation {
position: relative;
}
#logo {
position: absolute;
top: 0;
left: 0;
}
#logo a {
color: #fff;
text-decoration: none;
font-size: 32px;
}
#logo span {
font-size:20px;
color:#48bdee;
margin-left:50px;
}
If you're up to using javascript too, you could do the following.
Set the style of the div to show up as a mouse pointer when hovering over it:
.Logo { cursor:pointer; }
Then using javascript, have a url open with the onclick event:
<div class="Logo" onclick="window.open('google.com')" />

Displaying the link under the image

I'm displaying a set of thumbnail images with links on a webpage like this
Here's the HTML
<div id="newsletters-and-journals">
<p id="pubs-caption">Publications</p>
<ul>
<li class="pubs">
<img class="pub-cover" src="images/CXuyv.png" />
<span>Journal - January 2012</span>
</li>
<li class="pubs">
<img class="pub-cover" src="images/vER9H.png" />
<span>Newsletter - May 2012</span>
</li>
</ul>
</div>​
and the CSS
#newsletters-and-journals ul { position:relative; top:12px; left:30px; }
.pubs { display:inline; margin-right:60px; }
.pub-cover { width:120px; height:140px; }​
also a fiddle http://jsfiddle.net/nK0de/3jeVF/2/
How can I display the links under each corresponding image?
Thank you
It is also works:
.pubs {
display: inline-block;
margin-right: 60px;
width: 120px;
}
width is your image's width.
You can make either <img> or <span> to display:block
http://jsfiddle.net/3jeVF/6/
to solve your problem just add a
br
tag in between
img and span tag.