css image hover link - html

I have an image, and then a series of links. The hover works as intended on the text links, but when I place it on an image, in chrome and safari it only changes the background color for a portion of the image, not the whole thing...which I really dont understand. I tried jsfiddle as well as some of the other tools mentioned on SO, please look at the code below if you know why this is happening:
<html>
<head>
<title>Welcome!</title>
<style type="text/css">
#header {
background-color:#2C2C2C;
height:88px;
width:100%;
margin: 0px auto 0 auto;
}
#header_logo_link {
float: left;
width: 250px;
}
#header_logo_link img {
padding-right: 15px;
padding-left: 15px;
padding-top: 15px;
padding-bottom: 10px;
background: transparent;
}
#header_logo_link :hover {
background-color: #4d4d4d;
}
body, .wrapper {
min-height: 100%;
overflow: hidden;
margin: 0;
padding: 0;
min-height: 100%;
}
</style>
</head>
<body>
<div class="wrapper">
<div id="header">
<div id="header_logo_link">
<img src="logo.png">
</div>
<div id="header_logo_link">
Home
</div>
</div>
</div>
</body>
</html>

I'm not exactly sure what you're asking, but if you're trying to change the color around the image when it's rolled over, try adding some padding to the a element and display:block.
<html>
<head>
<title>Welcome!</title>
<style type="text/css">
#header {
background-color:#2C2C2C;
height:88px;
width:100%;
margin: 0px auto 0 auto;
}
#header_logo_link {
float: left;
width: 250px;
}
#header_logo_link img {
padding-right: 15px;
padding-left: 15px;
padding-top: 15px;
padding-bottom: 10px;
background: transparent;
}
#header_logo_link :hover {
background-color: #4d4d4d;
}
body, .wrapper {
min-height: 100%;
overflow: hidden;
margin: 0;
padding: 0;
min-height: 100%;
}
a.img_rollover{
padding:5px;
display:block;
}
a.img_rollover:hover{
background-color: #00F; /*This is your new rollover color*/
}
</style>
</head>
<body>
<div class="wrapper">
<div id="header">
<div id="header_logo_link" class="img_rollover">
<img src="logo.png">
</div>
<div id="header_logo_link">
Home
</div>
</div>
</div>
</body>
</html>

Related

Can't place image next to text (pushed into next div)

I want to place an image next to some text inside a div but the image was pushed into the next div below and won't move up no matter how much I increase the margin or padding. I want the center of the image to be where the tip of the arrow is in the picture:
Here's where the image is and where I want it to be
Here's the CSS and HTML:
.header {
padding: 10px 16px;
background: #1919ff;
color: #f1f1f1;
}
#about {
background-color: #ccccff;
height: 400px;
width: 67%;
margin: auto;
}
.round-border{
border-width: 0px;
border-style: solid;
border-radius: 50%;
}
.portrait-image{
width: 25%;
margin-bottom: 120%;
}
h9 {
font-size: 142%;
margin: auto;
padding-right: 30%;
padding-top: 12%;
display: inline-block;
}
.header-bar{
height: 3px;
width: 51%;
background: #272C31;
margin-right: 23%;
margin-top: 3%;
}
h10 {
font-size: 142%;
margin: auto;
padding-right: 24%;
padding-top: 5%;
display: inline-block;
}
#image position {
position: relative;
z-index: 1;
margin-botton: 40%;
padding-bottom: 20%;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<style>
img {
float: right;
}
.clearfix {
overflow: auto;
}
</style>
<div class="header" id="myHeader">
<h2> xxxxxxxxx</h2>
</div>
<body style="background-color: #5D6D7E;">
<div id="about" align="center" position="relative">
<h9><p align="right">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br/>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br/>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
</h9>
<div class="header-bar"></div>
<h10><p align="right">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
</h10>
<div id="image position"><img class="portrait-image round-border" align="right" src="http://abload.de/img/gpuxh.png" alt="portrait">
</div>
</div>
</body>
Any help would be greatly appreciated, thanks.
There were many things wrong with your code and I'm not sure where to begin. There are no h9 or h10 header tags. I would suggest using valid header tags and modifying the font-size according to your taste. Also, you can't have a class/id name separated by a space. So, "image position" will not work. Fixed it the best way I could.
.header {
padding: 10px 16px;
background: #1919ff;
color: #f1f1f1;
}
#about {
background-color: #ccccff;
height: 400px;
width: 67%;
margin: auto;
box-sizing: border-box;
}
.round-border {
border-radius: 50%;
}
.portrait-image {
width: 25%;
}
.header-bar {
height: 3px;
width: 51%;
background: #272C31;
margin-right: 23%;
margin-top: 3%;
}
#image-position {
float: right;
margin: 15% 5% 0 0;
}
#text {
float: left;
width: 57%;
word-break: break-all;
margin: 5%;
}
.clearfix {
/*clear the floats here*/
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<body style="background-color: #5D6D7E;">
<div class="header" id="myHeader">
<h2> xxxxxxxxx</h2>
</div>
<div id="about" class="clearfix">
<div id="text">
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br/>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
<div class="header-bar"></div>
<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
</div>
<img class="portrait-image round-border" id="image-position" src="http://abload.de/img/gpuxh.png" alt="portrait">
</div>
</body>
You can use CSS float. It is for elements that 'float' to the side of a text.
Try setting:
#image-position {
/* ... Your css here */
float: right;
}
More information here.
Use bootstrap to achive this, try the below code snippet.
<div class="container">
<div class="row">
<div class="col-md-8">
<p>
Your text goes here...
</p>
</div>
<div class="col-md-4">
<img src="">
</div>
</div>
</div>
I hope this helps,

CSS - Make page content fill all the screen height

I am new with CSS and need some help, please. Although it seems to be simple to solve, I am already working in this problem for about 4 hours. I found many similar questions on internet, but each case is particulary different from mine, and the "solutions" can't solve my problem (already tried most of them).
Here is the basic structure of my html page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title>Test</title>
</head>
<body>
<div id="main">
<div id="head">
<div id="head_content">
HEARDER
</div>
</div>
<div id="body">
<div id="menu">
MENU
</div>
<div id="page">
PAGE CONTENT
</div>
</div>
<div id="foot">
<div id="foot_content">
FOOTER
</div>
</div>
</div>
</body>
</html>
And here is the CSS I am trying to implement:
html {
height: 100%;
}
body {
margin:0;
padding:0;
width:100%;
height: 100%;
min-height: 100%;
background: #DEDEDE;
}
#main {
width: 100%;
min-height:100%;
position:relative;
}
#head {
width: 100%;
height: 58px;
border-bottom: 1px solid #115293;
background-color: #1976D2;
}
#head #head_content {
width: 1000px;
padding: 6px;
color: #FFFFFF;
margin: 0 auto;
text-align: center;
}
#body {
width: 1000px;
// height: 100%;
// min-height: 100%;
margin: 0 auto;
// padding-bottom: 50px;
border-left: 1px solid #BFBFBF;
border-right: 1px solid #BFBFBF;
}
#body #menu {
float: left;
width: 220px;
// height: 100%;
// min-height: 100%;
background-color: #94C9FF;
}
#body #page {
overflow: hidden;
// height: 100%;
// min-height: 100%;
padding: 10px;
color: #5C5C5C;
border-left: 1px solid #BFBFBF;
background-color: #FFFFFF;
}
#foot {
position:absolute;
bottom: 0;
left: 0;
width: 100%;
height: 58px;
color: #FFFFFF;
border-top: 1px solid #115293;
background-color: #1976D2;
}
#foot #foot_content {
position: relative;
width: 1000px;
padding: 6px;
margin: 0 auto;
text-align: center;
}
Obs: Commented lines are SOME of the solutions I already tried.
Here is what I got so far:
And finally here is what I really need:
The reason you were having trouble getting the #body div to be the full height of the remaining space is because each of the wrapping elements needed height:100% not just one of them. That means #main, #body, #page and #menu.
html {
height: 100%;
}
body {
margin:0;
padding:0;
width:100%;
height: 100%;
min-height: 100%;
background: #DEDEDE;
}
#main {
width: 100%;
min-height:100%;
position:relative;
height:100%;
}
#head {
width: 100%;
height: 58px;
border-bottom: 1px solid #115293;
background-color: #1976D2;
}
#head #head_content {
width: 1000px;
padding: 6px;
color: #FFFFFF;
margin: 0 auto;
text-align: center;
}
#body {
height:100%;
width: 1000px;
margin: 0 auto;
border-left: 1px solid #BFBFBF;
border-right: 1px solid #BFBFBF;
}
#body #menu {
float: left;
width: 220px;
background-color: #94C9FF;
height:100%;
}
#body #page {
overflow: hidden;
padding: 10px;
color: #5C5C5C;
border-left: 1px solid #BFBFBF;
background-color: #FFFFFF;
height:100%;
}
#foot {
position:absolute;
bottom: 0;
left: 0;
width: 100%;
height: 58px;
color: #FFFFFF;
border-top: 1px solid #115293;
background-color: #1976D2;
}
#foot #foot_content {
position: relative;
width: 1000px;
padding: 6px;
margin: 0 auto;
text-align: center;
}
<html >
<head>
<title>Test</title>
</head>
<body>
<div id="main">
<div id="head">
<div id="head_content">
HEARDER
</div>
</div>
<div id="body">
<div id="menu">
MENU
</div>
<div id="page">
PAGE CONTENT
</div>
</div>
<div id="foot">
<div id="foot_content">
FOOTER
</div>
</div>
</div>
</body>
</html>
you can add the following to css based on the size of content you require the content to be, just change the pixels based on the content you want:-
div#page {
width: 100%;
height: 600px;
}
I hope it will help
You can do this in the following way--
Just use the height unit as vh(viewport height) relative to viewport. Add rest of your css to get desired width effect.
checkout the snippet
#main {
background-color:blue;
height: 10vh;
}
#body {
background-color:grey;
height:80vh;
}
#foot {
background-color:blue;
height: 10vh;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<title>Test</title>
</head>
<body>
<div id="main">
<div id="head">
<div id="head_content">
HEARDER
</div>
</div>
<div id="body">
<div id="menu">
MENU
</div>
<div id="page">
PAGE CONTENT
</div>
</div>
<div id="foot">
<div id="foot_content">
FOOTER
</div>
</div>
</div>
</body>
</html>
You can find compatibility here---
vh compatibility
EDIT
As fallback for vh unit I think you can use javascript . Through javascript you can get the window size. Then specify the height of the footer as percentage of the window height.
This question can be good starting point

Fixed sidebar, scrollable content

I'm trying to create a webpage that will have a fixed sidebar and scrollable content. It does work if I don't have a header div. If I scroll page I have some empty space that previously was a header (i marked it with red color). I'd like my sidebar to cover the empty space after I scroll through header div.
Here's my HTML Code - how can I fix this?
<!doctype html>
<head>
<link rel="stylesheet" href="style.css"type=" text/css"/>
</head>
<body>
<div id="page">
<div id="header">
</div>
<div id="navigation">
<ul>
<li>home</li>
<li>news</li>
<li>contact</li>
<li>about</li>
</ul>
</div>
<div id="content">
<div id="abcd">
</div>
</div>
</body>
CSS
#page
{
position:relative;
width:100%;
height:3000px;
background-color:yellow;
}
#header
{
background-color: blue;
width:100%;
height:150px;
}
#navigation
{
background-color: red;
width:10%;
height:3000px;
float:left;
}
#content
{
float:left;
background-color: green;
width:90%;
overflow: auto;
height:1000px;
}
body
{
margin: 0;
}
ul
{
list-style-type: none;
margin: 0;
padding: 0;
width: 10%;
background-color: #f1f1f1;
position: fixed;
height: 100%;
overflow: auto;
}
li a
{
display: block;
color: #000;
padding: 8px 0 8px 16px;
text-decoration: none;
}
You have to place your navigation div in outermost part i.e. in body(not in any other div).
I have tested this and its now working fine.
Your new code should be
<html>
<head>
<link rel="stylesheet" href="style.css" type=" text/css" />
</head>
<body>
<div id="navigation">
<ul>
<li>home</li>
<li>news</li>
<li>contact</li>
<li>about</li>
</ul>
</div>
<div id="page">
<div id="header">
</div>
<div id="content">
<div id="abcd">
</div>
</div>
</div>
</body>
</html>
And your modified css:-
#page {
position: relative;
width: 100%;
height: 3000px;
background-color: yellow;
}
#header {
background-color: blue;
width: 100%;
height: 150px;
display: block;
}
#navigation
{
background-color: red;
width:10%;
height:100%;
float:left;
position: absolute;
z-index:1;
}
#content {
float: left;
background-color: green;
width: 90%;
overflow: auto;
height: 1000px;
}
body {
margin: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 10%;
background-color: #f1f1f1;
position: fixed;
height: 100%;
overflow: auto;
}
li a {
display: block;
color: #000;
padding: 8px 0 8px 16px;
text-decoration: none;
}
In css I have changed the navigation's height to 100% and its z-index to 1.
Also you didn't close the div tag with class "page".
Reference:- w3 css sidenav
Please try this:
#navigation {
background-color: red;
width: 10%;
height: 3000px;
float: left;
position: absolute;
z-index: 99999;
left: 0;
top: 0;
}

Transparent logo overlapping with the header menu

I am designing a header menu for my website. I want to place my logo on header menu such that I get something like this :
But, with my css, what I am getting is :
My CSS is :
*{
background-color: #DBDBDB;
}
.headerMenu{
background-image: url(../img/headerMenu.png);
height: 50px;
border-top: 0px;
border-bottom: 0px;
padding-top: 0px;
padding-left: auto;
padding-right: auto;
width: 100%
}
#wrapper{
background-image: url(../img/headerMenu.png);
margin-right: auto;
margin-left: auto;
width: 1000%;
padding-top: 0px;
padding-bottom: 0px;
}
.logo{
width: 80px;
}
.logo img
{
padding-left: 50px;
width: 150px;
height: 38px;
}
PS : The logo is transparent. I don't know why this is happening. Please help me out.
HTML :
<!doctype html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="./css/normalize.css">
<link rel="stylesheet" type="text/css" href="./css/style.css" />
</head>
<body>
<div class="headerMenu">
<div id="wrapper">
<div class="logo">
<img src="./img/logoS.png"/>
</div>
</div>
</div>
</body>
</html>
Remove background Color from
*{
background-color: #DBDBDB;
}
Make it as
body{
background-color: #DBDBDB;
}
Solution 1
Remove:
*{
background-color: #DBDBDB;
}
and only apply that to the elements you need (probably the body or .wrapper).
Solution 2
Remove the background of .logo and img
.logo, img {
background-color:none;
}

Position absolute and margin: auto

I've got a small problem, I want my footer to stay at the bottom of the screen with position: absolute. But my margin: auto to put it in the middle of the screen isn't working anymore.
html:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='Type=text/html; charset=utf-8'>
<link rel="shortcut icon" href="../IMAGES/favicon.ico">
<title>TEST</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../css/stylesheet.css">
</head>
<body>
<div id="header">
<div id="logo">
<img src="../IMAGES/logo.png" />
</div>
<div id="logotitel">
Den Allerstrafste "Ful-Ambi" Live-Band van groot Antwerpen en omstreken!
</div>
</div>
<div id="nav">
<div id="links">
<div class="link">Home</div>
<div class="link">Wie is wie</div>
<div class="link">Foto's</div>
<div class="link">Repertoire</div>
<div class="link">Links</div>
<div class="link">Contact</div>
</div>
</div>
<div class="clear"></div>
<div id="content">
TEST
</div>
<div class="clear"></div>
<div id="footer">
<div id="copy">
Developed by Yoshi &copy vAntstAd
</div>
</div>
</body>
</html>
CSS:
/* PAGE LAYOUT */
html
{
padding: 0px;
margin: 0px;
}
body
{
background-image: url(../IMAGES/background.png);
padding: 0px;
margin: 0px;
color: white;
font-family: 'Source Sans Pro', serif, sans-serif;
}
.clear
{
clear: both;
}
/* HEADER */
#header
{
width: 1100px;
height: 150px;
background-color: #282828;
margin: auto;
border-bottom: solid;
border-color: red;
}
#logo
{
width: 283px;
height: 100px;
margin: auto;
}
#logotitel
{
width: 1100px;
height: 50px;
line-height: 50px;
text-align: center;
font-size: x-large;
}
/* NAV */
#nav
{
width: 1100px;
height: 50px;
margin-top: 25px;
margin-right: auto;
margin-left: auto;
margin-bottom: 25px;
background-color: red;
}
#links
{
width: 600px;
height: 50px;
margin: auto;
}
.link
{
width: 100px;
height: 50px;
line-height: 50px;
float: left;
text-align: center;
color: white;
text-decoration: none;
}
.link:hover
{
color: #282828;
text-decoration: underline;
}
/* CONTENT */
#content
{
width: 1100px;
height: auto;
margin: auto;
color: #282828;
position: relative;
}
/* FOOTER */
#footer
{
width: 1100PX;
height: 50px;
position: absolute;
bottom: 0;
margin: auto;
background-color: #282828;
}
#copy
{
width: auto;
float: right;
margin-right: 5px;
height: 50px;
line-height: 50px;
}
Since you know the width of the footer (1100px), you can just do a left:50%;margin-left:-550px to center it.
Example: Centering an absolutely positioned element
http://jsfiddle.net/vdWQG/
Therefore, footer would become:
#footer
{
width: 1100PX;
height: 50px;
position: absolute;
bottom: 0;
left:50%; /* Add this */
margin-left:-550px; /* Add this (this is half of #footers width) */
background-color: #282828;
}
If you want the element to stick on the bottom of the page as the user scrolls down, use position: fixed instead of position:absolute
To have a footer at the bottom, centered horizontally, you can apply the following CSS:
footer{
width: 100%;
max-width: 600px;
position: fixed;
left: 0;
right: 0;
bottom: 0;
margin: 0 auto;
}
This will center the fixed element, but will also keep it responsive, as it will shrink when the browser has become less wide than the footer.
See this Fiddle for an example