Remove overflowing clickable area - html

I have a navbar with a certain height and a logo that overflows. This logo is, of course, clickable, but it means that the part that overflows, is also clickable.
Is it possible to make the logo overflow, but not the clickable area?
HTML
<nav>
<a href="#">
<div class="logo">
<img src="http://i.imgur.com/h4bUdrZ.png" />
</div>
</a>
</nav>
CSS
body, html {
padding: 0;
margin: 0;
}
nav {
height: 100px;
background: blue;
position: relative;
}
.logo {
position: absolute;
top: -36px;
left: -39px;
}
JSFIDDLE

Something like this?
body,
html {
padding: 0;
margin: 0;
}
nav {
height: 100px;
background: blue;
position: relative;
}
a {
display: inline-block;
height: 100%;
width: 100%;
}
.logo {
position: absolute;
top: -36px;
left: -39px;
pointer-events: none;
}
<nav>
<a href="#">
<div class="logo">
<img src="http://i.imgur.com/h4bUdrZ.png" />
</div>
</a>
</nav>

Just move logo outside of your link and put that link on rest of header:
body,
html {
padding: 0;
margin: 0;
}
nav {
height: 100px;
background: blue;
position: relative;
}
.logo {
position: absolute;
top: -36px;
left: -39px;
}
a {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 10;
display: inline-block;
}
<nav>
<a href="#">
</a>
<div class="logo">
<img src="http://i.imgur.com/h4bUdrZ.png" />
</div>
</nav>

Change little bit of you structure.
Put <a> independent and pass link in it with following css.
HTML
<nav>
<div class="logo">
<img src="http://i.imgur.com/h4bUdrZ.png" />
</div>
</nav>
CSS
body, html {
padding: 0;
margin: 0;
}
nav {
height: 100px;
background: blue;
position: relative;
}
nav a{
position: relative;
display: block;
height: 100%;
z-index: 1;
}
.logo {
position: absolute;
top: -36px;
left: -39px;
}
Example : https://jsfiddle.net/67s4ajqf/3/

Don't place the whole div inside the a.
Place the link after the image, give it absolute positioning and carefully set the position and size.
The other answers make the whole header clickable. If it is not desired, use this solution. You may have to adjust the width of the clickable area.
See the example below:
body, html {
padding: 0;
margin: 0;
}
nav {
height: 100px;
background: blue;
position: relative;
}
.logo {
position: absolute;
top: -36px;
left: -39px;
}
a.clickable-logo {
position: absolute;
display: inline-block;
left: 36px;
top: 36px;
width: 600px;
height: 100px;
}
<nav>
<div class="logo">
<img src="http://i.imgur.com/h4bUdrZ.png" />
<a href="#" class="clickable-logo">
</a>
</div>
</nav>

What about something like this?
HTML
<a href="#">
<div class="clear">
</div>
</a>
<nav>
<div class="logo">
<img src="http://i.imgur.com/h4bUdrZ.png" />
</div>
</nav>
CSS
body, html {
padding: 0;
margin: 0;
}
nav {
height: 100px;
background: blue;
position: relative;
}
.clear {
height: 100px;
background: 0;
position: absolute;
width: 100%;
z-index: 2;
}
.logo {
position: absolute;
top: -36px;
left: -39px;
}

Related

Div elements in position relative will not stack

In summary, I made a container div (parent) with a position: relative, then added 3 children divs with position: absolute. I am now trying to add another div that is below all of this, i.e. the next section of a website. But now the next div appears under the first main "parent" div. From endless searching on here and google I though a main div with position relative would not destroy the flow, but obviously it did or else I would't be posting.
I now want to have another div outside of the parent so that it will go under this first div and make for a nice, scolling website. Please look at my CSS and help me understand why the absolute elements inside a relative element messed up the flow. (I'm new to CSS, so any pro tips are appreciated!)
Here is an image of the website so you get a feel
*{
margin: 0;
padding: 0;
border: 0;
}
body {
font-family: 'Noto Sans HK', sans-serif;
}
/* Arranging the parent and child elements so
images can overlap */
.child {
top: 0;
}
.child-1 {
position: absolute;
left: 0;
z-index: 100;
}
.child-2 {
position: absolute;
right: 0;
z-index: 1;
}
.child-3 {
position: absolute;
padding-top: 38%;
left: 0;
}
#parent {
position: relative;
height: auto;
}
.hero-text {
position: absolute;
text-align: center;
right: 10vw;
top: 28vw;
z-index: 9;
font-size: 3.5vw;
float: right;
color: white;
}
/* Responsive viewport area,
Logo resize based on the screen size */
#logo_png {
max-width: 25vw;
}
#hero_img {
max-width: 85vw;
}
#green_circle_png {
max-width: 40vw;
}
/* NAV BAR STYLING */
#container {
position: absolute;
z-index: 900;
width: 95%;
margin: 0 auto;
}
nav {
float: right;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 5vw; /* margin-left obly touches the left margin, not L & R */
padding-top: 25px;
position: relative;
}
nav a {
color: white;
text-decoration: none;
text-transform: uppercase;
font-size: 1.4vw;
}
nav a:hover {
color: black;
}
.p1 {
color: #f5f7ff;
font-size: 10vw;
}
#test {
position: relative;
}
<body>
<div id="parent">
<div class="child child-1">
<h1>
<a href='THIS WILL BE LINK TO HOME PAGE'>
<img id="logo_png" src="C:\Users\rebec\Desktop\LBS WEBSITE\Images\lbs_blue_circle_logo_1500x1500.png" alt="Little Big Scientists"/>
</a>
</h1>
</div>
<div class="child child-2">
<h1>
<img id="hero_img" src="Images/circle_hands_lbsphoto.png" alt="Little Big Scientists"/>
</h1>
</div>
<div class="child child-3">
<h1>
<img id="green_circle_png" src="Images/green_circle_lbswebsite.png" alt="Little Big Scientists"/>
</h1>
</div>
<div class="hero-text">
<p>We’re on a mission to teach,
<br>guide, and empower the next
<br> generation of scientists
</p>
</div>
<!-- Div for Nav Bar-->
<div id="container">
<nav>
<ul>
<li>Mission</li>
<li>About</li>
<li>Events</li>
<li>Donate</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
<div id="test">
<h2 class="p1">Inspiring Education</h2>
</div>
<h2 class="p1">HELP MEEEE</h2>
</body>
I don't think there's necessarily anything wrong with using absolute positioning for some elements. The main problem you are experiencing is that because everything inside #parent is absolute positioning #parent collapses and has zero height. If you want to do overlapping circles, absolute positioning is a valid way to do it, but you have to expressly set a height for #parent.
Below is a modified copy of your code. I want to emphasize it is a very rough starting point, and by no means is it complete, but I think it demonstrates some of the things you can do. Even with absolute positioning of the circle elements it is still fairly responsive and it could be made fully responsive by adding appropriate media queries to the css.
*{
margin: 0;
padding: 0;
border: 0;
box-sizing: border-box;
}
body {
font-family: 'Noto Sans HK', sans-serif;
}
/* Arranging the parent and child elements so
images can overlap */
.child {
position: absolute;
}
.child-1 {
top: -75px;
left: -75px;
z-index: 100;
width: 300px;
height: 300px;
max-width: 50vw;
max-height: 50vw;
background: blue;
border-radius: 50%;
}
.child-1 h1 {
position: absolute;
right: 10%;
bottom: 20%;
background: white;
}
.child-2 {
right: -40vw;
top: -50vw;
z-index: 1;
width: 120vw;
height: 120vw;
background: center / contain no-repeat url("./Images/circle_hands_lbsphoto.png"), content-box linear-gradient(lightgray, lightgray);
border-radius: 50%;
}
.child-3 {
top: 60vh;
left: -5vw;
width: 550px;
height: 550px;
max-width: 50vw;
max-height: 50vw;
border-radius: 50%;
background: lightgreen;
}
#parent {
position: relative;
min-height: 100vh;
height: 550px;
width: 100vw;
overflow: hidden;
}
.hero-text {
position: absolute;
text-align: center;
left: 40%;
transform: translateX(-50%);
top: 60%;
z-index: 9;
font-size: 3.5vw;
color: white;
}
/* Responsive viewport area,
Logo resize based on the screen size */
#logo_png {
max-width: 25vw;
}
#hero_img {
max-width: 85vw;
}
#green_circle_png {
max-width: 40vw;
position: absolute;
bottom: 20%;
left: 20%;
}
/* NAV BAR STYLING */
#container {
z-index: 900;
width: 100%;
margin: 0 auto;
position: sticky;
top: 0;
background: #fff;
}
nav {
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 5vw; /* margin-left obly touches the left margin, not L & R */
padding-top: 25px;
position: relative;
}
nav a {
color: black;
text-decoration: none;
text-transform: uppercase;
font-size: 1.4vw;
}
nav a:hover {
color: black;
}
.p1 {
color: #f5f7ff;
font-size: 10vw;
}
#test {
position: relative;
}
<body>
<div id="parent">
<div class="child child-1">
<h1>
<a href='THIS WILL BE LINK TO HOME PAGE'>
<img id="logo_png" src="C:\Users\rebec\Desktop\LBS WEBSITE\Images\lbs_blue_circle_logo_1500x1500.png" alt="Little Big Scientists 1"/>
</a>
</h1>
</div>
<div class="child child-2">
<img id="hero_img" alt="Little Big Scientists 2"/>
<div class="hero-text">
<p>We’re on a mission to teach,
<br>guide, and empower the next
<br> generation of scientists
</p>
</div>
</div>
<div class="child child-3">
<h1>
<img id="green_circle_png" src="Images/green_circle_lbswebsite.png" alt="Little Big Scientists 3"/>
</h1>
</div>
</div>
<!-- Div for Nav Bar-->
<div id="container">
<nav>
<ul>
<li>Mission</li>
<li>About</li>
<li>Events</li>
<li>Donate</li>
<li>Contact</li>
</ul>
</nav>
</div>
<div id="test">
<h2 class="p1">Inspiring Education</h2>
</div>
<h2 class="p1">HELP MEEEE</h2>
</body>

Want to fix this page background

I want to fix this page (http://l2topserver.com/l2topserver) just to have a right banner link. I made this code
but when the screen's resolution the page is broken in the right side. What settings can I use that the page won't break?
First snippet
.header11 a {
display: block;
background-image: url("http://www.l2topserver.com/test/1.jpg");
padding-left: 395px;
padding-top: 1000px;
width: 100px;
left: 5px;
top: 10px;
position: fixed;
}
<div class="header11">
<div align="left">
<a href="https://www.google.com" target="_blank">
</a>
</div>
</div>
Second snippet
.header111 a {
display: block;
background-image: url("http://www.l2topserver.com/test/2.jpg");
padding-left:395px;
padding-top:1000px;
width:100px;
left: 1410px; top: 10px;
position: fixed;
overflow: auto;
}
<div class="header111">
<div align="right">
<a href="https://www.google.com" target="_blank">
</a>
</div>
</div>
You can use right: 0; in the second image.
.header11 a {
display: block;
background-image: url("http://www.l2topserver.com/test/1.jpg");
padding-left:395px;
padding-top:1000px;
width:5%;
left: 5px; top: 10px;
position: fixed;
}
.header111 a {
display: block;
background-image: url("http://www.l2topserver.com/test/2.jpg");
padding-left:395px;
padding-top:1000px;
width:5%;
right: 0;
top: 10px;
position: fixed;
overflow: auto;
}

text-align and margin CSS properties are not responsive

.scss
div.playlist {
position: relative;
display: inline-block;
}
div.playlist {
span {
position: absolute;
text-align: center;
height: 100%;
width: 100%;
color: white;
font-size: 20px;
}
.span-icon {
padding-bottom: 50px !important;
}
}
div.playlist span:before {
display: inline-block;
vertical-align: middle;
height: 100%;
content: '';
}
.html
<div class="playlist">
<span class="span-icon"><ion-icon [name]="data.icon"></ion-icon></span>
<span>{{data.text}}</span>
<img [src]="data.imageUrl" [alt]="data.text" />
</div>
Out Put
Now I need as shown below.Please don't consider about the different icon type and the text.I just need this.I need a responsive top right and the bottom right appearance of the icon and text.I have tried with text-align: right and the margin properties.But you know that approach is not responsive on different view ports.So can you help me to solve this issue?
Position your both icons and span text as absolute and then if needed you could use CSS calc() function to align them at top-right and bottom-right above the image.
.playlist {
position: relative;
display: inline-block;
width: 240px;
height: 200px;
overflow: hidden;
}
.playlist img {
width: 100%;
height: 100%;
}
.playlist .span-icon {
position: absolute;
top: 5px;
right: calc(100% - 98%);
color: #fff;
}
.playlist .tm {
position: absolute;
bottom: 5px;
right: calc(100% - 98%);
color: #fff;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="playlist">
<span class="span-icon"><i class="fa fa-film"></i></span>
<span class="tm">2:10</span>
<img src="http://lorempixel.com/output/city-q-c-640-480-6.jpg">
</div>
<div class="playlist">
<span class="span-icon"><ion-icon [name]="data.icon"></ion-icon></span>
<span class="span-text">{{data.text}}</span>
<img [src]="data.imageUrl" [alt]="data.text" />
</div>
CSS
.span-icon {
position: absolute;
top: 0;
right: 0;
}
.span-icon {
position: absolute;
bottom: 0;
right: 0;
}
You simply set the icons absolute and position it with top, right. ...

IE7: Hover an Image will show another image at different place

I have a few images one on top of each other in a form of a "menu".
I would like that while I hover one of the images, it will show another image.
I also would like that while hovering each image, it will go up by 5px (currently it does not).
It must support Internet Explorer 7 or higher.
I hope what I have requested is possible and really appreciate any help you can provide.
My code so far:
.hw { font-size: 50px; padding: 50px; }
.first {
position: relative;
top: 0;
left: 0;
}
.second {
position: absolute;
right: 180px;
}
.third {
position: absolute;
right: 360px;
}
.logo {
position: relative;
bottom:60px;
left: 100px;
}
.first:hover, .second:hover, third:hover {
bottom: 5px;
}
.hidden {
display: none;
}
.logo:hover .hidden {
display: block;
}
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body dir="rtl">
<p class="hw">Hello World!</p>
<img class="hidden" src="http://i.imgur.com/MY5bRT1.jpg" style="position: relative; bottom: 80px; right: 500px;"/>
<div style="position: relative; left: 0; top: 0;">
<img class="first" src="http://i.imgur.com/cr2cqPA.png"/>
<img class="second" src="http://i.imgur.com/MY5bRT1.jpg"/>
<img class="third" src="http://i.imgur.com/cr2cqPA.png"/>
<img class="logo" src="http://i.imgur.com/MY5bRT1.jpg"/>
</div>
</body>
</html>
EDIT: solution:
.hw {
font-size: 50px;
padding: 50px;
}
.menu {
margin-right:300px;
}
.first {
position: relative;
top: 0;
}
.second {
position: absolute;
right: 180px;
}
.third {
position: absolute;
right: 360px;
}
.forth {
position: absolute;
right: 540px;
}
.logo {
position: relative;
bottom:60px;
left: 100px;
}
.first:hover, .second:hover, .third:hover, .forth:hover {
margin-top: 3px;
}
.img-con {
position: relative;
width: 300px;
padding-top: 50px;
z-index: 9998;
}
.img-con > img {
position: absolute;
top: 0;
left: 0;
}
.img-con > img.logo {
z-index: 1;
}
.img-con:hover > img.logo {
z-index: -1;
margin-top: 3px;
}
.img-con:hover > img.hidden {
top: -100px;
right: 500px;
}
<!DOCTYPE html>
<html>
<head>
<title>bla bla</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body dir="rtl"><div class="center">
<p class="hw">Hello World!</p>
<div class="menu" style="position: relative; left: 0; top: 0;">
<div class="img-con">
<img class="logo" src="http://i.imgur.com/cr2cqPA.png"/>
<img class="hidden" src="http://i.imgur.com/MY5bRT1.jpg"/>
</div>
<img class="first" src="http://i.imgur.com/cr2cqPA.png"/>
<img class="second" src="http://i.imgur.com/MY5bRT1.jpg"/>
<img class="third" src="http://i.imgur.com/cr2cqPA.png"/>
<img class="forth" src="http://i.imgur.com/MY5bRT1.jpg"/>
</div>
</div></body>
</html>
I found a solution for you. You need insert every two image to container and set him with Relative position. Your images sets by Absolute position and you can play with there z-index on :hover to get the resolute.
Here we go:
.img-con {
position: relative;
width: 400px;
margin: 20px;
}
.img-con > img {
position: absolute;
top: 0;
left: 0;
}
.img-con > img.first {
z-index: 1;
}
.img-con:hover > img.first {
z-index: -1;
}
.img-con:hover > img.second {
top: -5px;
left: 5px;
}
<div class="img-con">
<img class="first" src="http://i.imgur.com/cr2cqPA.png"/>
<img class="second" src="http://i.imgur.com/MY5bRT1.jpg"/>
</div>

How do I correctly fromat this div's contents?

I'm trying to improve my basic design "skills". I'm attempting to recreate this:
but I don't know how to format it correctly with the right css.
.container {
width: 40%;
height: 107px;
background: #fff;
position: relative;
}
.cover {
position: absolute;
left: 10px;
top: 5px;
}
.icon {
position: absolute;
right: 10px;
bottom: 10px;
}
#container h3, p {
color: #000;
position: absolute;
left: 60px;
top: 15px;
margin: 5px;
}
<div class="container">
<img class="cover" src="book.png" width="45" height="60"/>
<h3>Title of Something</h3>
<p> Cracking the code </p>
<img class="icon" src="icon.png" width="45" height="40"/>
</div>
Any suggestions?
Here is the way to fix the issue, your html working fine
only the css need to be edit.
CSS
.container {
width: 40%;
height: 107px;
background: #fff;
position: relative;
float:left
}
.cover {
position: absolute;
left: 10px;
top: 5px;
}
.icon {
position: absolute;
right: 10px;
bottom: 10px;
top: 15px
}
h3, p {
color: #000;
position: relative;
left: 60px;
top: 15px;
margin: 5px;
}
DEMO
here is a very simple solution: http://codepen.io/elstermann/pen/oXRVxG
HTML
<header>
<img id=img-book alt=book src=http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png width=158 height=158>
<div id=title>
<h3>Title of Something</h3>
<p id=h1-sub>Title of Something</p>
</div>
<img id=img-face alt=book src=http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png width=158 height=158>
</header
CSS
header {
margin: 0 auto;
max-width: 950px;
min-width: 500px;
width: 90%;
}
#img-book, #title {
float: left;
}
#img-face {
float: right;
}