I am trying to place one on top of another at my website finegra.in. Here is a screenshot of the site right now:
I just want the "visit our kickstarter project" img to go right here:
Here are the html and stylesheets:
<div id="page" class="hfeed">
<header id="branding" role="banner">
<!--
<nav id="access" role="navigation">
<h3 class="assistive-text">Main menu</h3>
<div class="skip-link"><a class="assistive-text" href="#content" title="Skip to primary content">Skip to primary content</a></div>
<div class="skip-link"><a class="assistive-text" href="#secondary" title="Skip to secondary content">Skip to secondary content</a></div>
<div class="menu"><ul><li class="current_page_item">Home</li></ul></div>
</nav><!~~ #access ~~>
-->
<hgroup>
<div>
<a href="http://www.finegra.in"><img id="logo" alt="fine grain Logo" src="http://www.finegra.in/wp-content/uploads/2012/04/fineGRAINlogoGOOD-WEB.png">
</a>
<img id="headerimg" alt="The Sheffield Case" src="http://www.finegra.in/wp-content/uploads/2012/04/headerimg2.jpg">
<a href="http://www.kickstarter.com/projects/finegrain/17408941?token=364cb635"><img id="branding" alt="The Sheffield Case" src="http://www.finegra.in/wp-content/uploads/2012/04/checkOurProject.png">
</a>
</div>
<div id="site-generator">
FineGrain LLC Copyright 2012. All Rights Reserved
</div>
</hgroup>
</header><!-- #branding -->
style.css:
#branding {
border-top: 0px solid #BBBBBB;
padding-bottom: 10px;
position: relative;
z-index: 9999;
background: none repeat scroll 0 0 #DADAD2;
}
#headerimg {
width: 30% !important;
width: 100% !important;
}
#branding img {
margin-bottom: 20px;
width: auto;
}
.one-column #page {
max-width: 1500px;
}
.one-column #content {
margin: 0;
width: auto;
}
Assuming you are using jQuery, you may create the watermarks for your images at the DOM ready function and make theirs position absolute and calculated relative to the images.
<script type="text/javascript">
// Watermark image, change the src with your image's url
var watermark = '<img src="watermark.png" border="0" style="border:none; background-color:transparent; position:absolute; ';
// Position relative to image inside:
var insideTop = 20;
var insideLeft = 50;
$(document).ready(function () {
$("img").each(function (ix, el) {
var top = $(this).offset().top + insideTop;
var left = $(this).offset().left + insideLeft;
var imgWatermark = watermark + 'top:' + top + 'px; left:' + left + 'px;"/>';
$("body").append(imgWatermark);
});
});
</script>
If you have images that will have the watermark and images that won't, add an attribute class="withWatermark" to the images that will have and replace the $("img") in the script with $(".withWatermark").
<img src="myimage.jpg" class="withWatermark" />
$(".withWatermark").each(function (ix, el) {
How about something like this? http://jsfiddle.net/UtKbC/
CSS:
.visit_project {
position: absolute;
top: 250px;
left: 400px;
}
HTML:
<a href="http://www.kickstarter.com/projects/finegrain/17408941?token=364cb635" class="visit_project"><img id="branding" alt="The Sheffield Case" src="http://www.finegra.in/wp-content/uploads/2012/04/checkOurProject.png">
</a>
It might be wiser to wrap the header image in it's own div and set the checkOurProject.png image to the absolute value based on that div wrapper.
I think you can do this easily by simple css with the help of float :-
CSS
#header {
background: url("http://i.imgur.com/1nrC6.jpg");
width:1040px;
height:402px;
}
.logo {
float:right;
margin-top:200px;
}
HTML
<div id="header">
<img class="logo" src="http://i.imgur.com/17oqa.png"border="0"/>
</div>
see the demo:- http://jsfiddle.net/UtKbC/6/
Related
I'm trying to make a php gallery and thats why I need a good Mask, where the pictures later can be shown.
I want the Mask not to be bigger than screen-size. I mean, there must be no scrolling and the whole <body> needs to have just the width and height of the browser windows, so that every child object in <body> is limited to the frame-size of the browser and will be shrunk down if it overflows. I've tried with max-width and max-height on the <body>, but it doesn't work.
Here are the contents of my index.html file:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="mother">
<div id="header">
<div id="back-link">
Home
</div>
<div id="prev">
next picture
</div>
<div id="next">
previous picture
</div>
<div id="headline">
<p class="h2">Our Galery</p>
</div>
</div>
<!-- Content -->
<div id="container-bild">
<img src="./bilder/P1130079.JPG" id="img-bild" />
</div>
</div>
</body>
</html>
Here are the contents of my style.css file:
body {
max-width: 100%;
max-height: 100%;
}
/* mother-container */
div#mother {
max-width: 100%;
max-height: 100%;
margin: auto;
}
/* main-container */
#container-bild {
max-width: 100%;
max-height: 100%;
}
/* picture in main-container */
#img-bild {
max-width: 100%;
max-height: 100%;
border: 1px solid #280198;
}
Here is a screenshot of what it looks like:
To set the height and width to be 100% of the window (viewport) size, use:
height: 100vh;//100% view height
width: 100vw;// 100% view width
.
div {
background-color: blue;
height: 100vh;
width: 100vw;
position: absolute;
top: 0;
left: 0;
color: white;
}
<div>some content here</div>
Try:
html,
body {
height: 100%;
}
body {
overflow: hidden;
}
Do you know how many child elements will be in your gallery? If the number of elements is static, you could simply set their dimensions in CSS using vw and vh units. No JavaScript involved, and the elements would never be able to overflow your body.
As a reminder for my future self:
.book {
margin: auto;
width: 100vh;
max-width: 100vw;
min-width: 500px;
}
Though this is completely unrelated, for links, you might want to use something like:
a[href^="#"] {
text-decoration: none;
color: black;
background: url("http://www.yaml.org/spec/1.2/term.png") no-repeat bottom right;
}
a[href^="#"]:hover {
text-decoration: underline;
color: blue;
background: none;
}
I'm not sure if this is possible with css, it could be.
I have solved similar issue with javascript:
window.top.innerHeight;
gets the available height, excluded menubars etc. of the borwser.
See how I did for the height, my issue was that the footer should be at the bottom even if content was empty->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>C-Driver Manager</title>
<meta name="keywords" content="Aygit,Device,Driver,Surucu,Download,Indir,yedekle,Unknown,Bilinmeyen,Backup,Back-up,stuurprogramma,apparaat,windows,w7,w8,w10,multilanguage,tool,free,gratis,ucretsiz">
<meta name="description" content="Windows 7/8/10 Device indentify, Driver backup, Driver info">
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="icon" href="images/favicon.ico">
</head>
<body onResize="resizecontainer();">
<div class="divtop">
<div class="divtopcontainer">
<div class="divlogo">
</div>
<div class="divHmenu">
<style>
.mnuHorizontal
{
list-style:none;
}
.mnuHorizontal li
{
float:left;
}
.mnuHorizontal .activemnu a,.mnuHorizontal li a:hover
{
background:#00B7EF;
border-radius:5px;
color:white;
}
.mnuHorizontal li a
{
display:inline-block;
text-decoration:none;
padding:5px 12px;
text-align:center;
font-weight:bold;
color:#020042;
}
</style>
<ul class="mnuHorizontal">
<li id="index.php">HOME</li>
<li id="features.php">FEATURES</li>
<li id="download.php" class="activemnu">DOWNLOAD</li>
<li id="contact.php">CONTACT</li>
</ul>
</div>
</div>
</div>
<div class="divblueline"></div>
<div class="divcontainer">
<div style="float:left">
<h2>What is C-Driver Manager</h2>
C-Driver Manager is a simple tool that;
<ul>
<li>displays information about your devices</li>
<li>identify unrecognized devices by windows</li>
<li>Backups your devices driver</li>
</ul>
<h2>Why C-Driver Manager?</h2>
<ul>
<li>No installation needed</li>
<li>No adware</li>
<li>No spyware</li>
<li>Absolutely freeware</li>
</ul>
</div>
<div>
<img alt="" src="images/devmgr5.jpg" height="430" width="700">
</div>
</div>
<div class="divblueline"></div>
<div class="divbottom">
<div id="chmx">
</div>
</div>
</body>
<script>
for (i=0;i<document.getElementsByClassName('mnuHorizontal').item(0).children.length; i++)
{
if (document.getElementsByClassName('mnuHorizontal').item(0).children[i].id ==
"index.php")
{
document.getElementsByClassName('mnuHorizontal').item(0).children[i].className = 'activemnu';
}
else
{
document.getElementsByClassName('mnuHorizontal').item(0).children[i].className = '';
}
}
resizecontainer();
function resizecontainer()
{
avh = window.top.innerHeight;
dbh = document.getElementsByClassName('divbottom').length *
document.getElementsByClassName('divbottom').item(0).clientHeight;
dbt = document.getElementsByClassName('divtop').length *
document.getElementsByClassName('divtop').item(0).clientHeight;
dbbl = document.getElementsByClassName('divblueline').length *
document.getElementsByClassName('divblueline').item(0).clientHeight;
decrh = dbh + dbt + dbbl;
document.getElementsByClassName('divcontainer').item(0).style.minHeight = (avh - decrh) + 'px';
}
</script>
</html>
look for this function inside the example above ->
function resizecontainer()
{
avh = window.top.innerHeight;
dbh = document.getElementsByClassName('divbottom').length *
document.getElementsByClassName('divbottom').item(0).clientHeight;
dbt = document.getElementsByClassName('divtop').length *
document.getElementsByClassName('divtop').item(0).clientHeight;
dbbl = document.getElementsByClassName('divblueline').length *
document.getElementsByClassName('divblueline').item(0).clientHeight;
decrh = dbh + dbt + dbbl;
document.getElementsByClassName('divcontainer').item(0).style.minHeight = (avh - decrh) + 'px';
}
This works great. This will keep your image from growing too large width wise and also keep its proportions.
img {
max-width: 100%;
height: auto;
}
My CSS solution is:
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
My text/header is not showing over my image which I'm trying to use as a background to this webpage. This is the code I have right now:
HTML:
<body id="body">
<div id="navbar">
<h1 id="name">Lorem ipsum</h1>
<img class="backgroundimg" src="leaf.jpg" alt="A leaf"/>
</div>
<div class="backimg">
<img class="backgroundimg" src="buildings.jpg"/>
</div>
<div class="backimg">
<img class="backgroundimg" src="squares.jpg"/>
</div>
</body>
CSS:
body {
background-color:black
}
backgroundimg {
position:relative;
width:1175px;
}
name {
position:absolute;
color: white;
z-index;
}
Any tips?
P.S. I took out the '#' and '.' to the appropriate names in CSS.
Use z-index to show the text over image.
You can use z-index, like Anil Panwar said(https://stackoverflow.com/a/34374513/4900669)
#name {
position:absolute;
color: white;
z-index: 10;
}
https://jsfiddle.net/08voh0fp/
Add this to your css file
h2 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
adjust top,left and width according your need,
let me know if this helped
first of all, here's a Reference to what I want to do, based my code off that one.
I'm having a bit of trouble using css, I have a php file that returns a table with images:
echo '<td valign="bottom">
<div class="profile-image">
<figure>
<img src="'.$image.'" width="250px" height="200px" />
<figcaption>'.$nombreAlmno.'<br>'.$semestre.' semestre</figcaption>
</figure>
<span class="overlay"></span>
</div>
</td>';
It does work, this is what I get:
So my problem is I'm trying to display another image on hover using the <span class="overlay"> which I call on my css file:
.profile-image:hover .overlay {
position:absolute;
width: 800px;
height: 800px;
z-index: 100;
background: transparent url('http://farm4.static.flickr.com/3261/2538183196_8baf9a8015.jpg') no-repeat;
cursor: pointer;
}
I know my css is working (part of it at least) because when I put the cursor over an image, it changes to the pointer cursor, yet the span is not showing at all.
Any tips or tricks would be appreciated.
You need the parent element (the one that the absolute positioning is being set relative to) to have a set position (in this case, position:relative is probably best). Also, be sure to set the top, bottom, left, or right properties to control where the image appears!
http://jsfiddle.net/gztLspL3/4/
HTML:
<table>
<td valign="bottom">
<div class="profile-image">
<figure> <a href="#">
<img src="http://farm4.static.flickr.com/3261/2538183196_8baf9a8015_s.jpg" width="250px" height="200px" />
</a>
<figcaption>'.$nombreAlmno.'
<br>'.$semestre.' semestre</figcaption>
</figure> <span class="overlay"></span>
</div>
</td>
CSS:
.profile-image {
position: relative;
}
.profile-image:hover .overlay {
position: absolute;
width: 800px;
height: 800px;
z-index: 100;
background: transparent url('http://farm4.static.flickr.com/3261/2538183196_8baf9a8015.jpg') no-repeat;
cursor: pointer;
left: 100%;
top: 0;
}
Also, if you want it to appear directly next to the image:
http://jsfiddle.net/gztLspL3/6/
Add jquery like this
$( "div.profile-image>a>img" ).hover(
function() {
$( "#bigOne").first().css("display", "block").css("background", "transparent url('" + $(this).prop("src").replace("_s.jpg", ".jpg") + "') no-repeat");
}, function() {
$( "#bigOne" ).css("display", "none").css("background", "");
}
);
and change your css name
#bigOne {
position:absolute;
width: 800px;
height: 800px;
z-index: 100;
cursor: pointer;
display:none;
}
and change <span class="overlay"></span> to <span id="bigOne"></span>
dont forget adding jquery your page
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
I want to click only on left side where is letter "F" and other section to make not clickable. I am trying with css class diver but not work.
Html
<a href="https://www.google.com" class="diver" target="_blank">
<div style="margin-top:0px;">
<img src="http://www.upslike.net/imgdb/facebook-4846a5.png" width="30%" height="60px">
</div>
</a>
CSS
<style>
.diver a{
display:block;
width:100px;
height:60px;
}
</style>
CodePen
If the image must be in the HTML.
Note: The "universal reset" (the * section) have an effect on elements outside the scope of the current question. Headers, paragraphs and lists spring to mind.
* {
margin: 0;
padding: 0;
}
.diver-wrap {
display: inline-block;
position: relative;
margin: 1em;
}
a.diver {
position: absolute;
top:0;
left: 0;
width:100px;
height:60px;
background: rgba(0,0,0,.25); /* for visual reference */
}
<div class="diver-wrap">
<img src="http://www.upslike.net/imgdb/facebook-4846a5.png" alt=""/>
</div>
here's what I'm using
<h1>Red to Violet</h1>
first .
second .
<div id="section">
<div class="innersections">
<a name="one"></a>
(text)
</div> <hr>
<div class="innersections">
<a name="two"></a>
(text)
</div></div>
I want it so that when I click a link, it doesn't take the page up and I can't see the title 'red to violet' but I can see the second 'innersections' if I clicked 'second'.
note; I can only use css/html codes.
Use id with element you want to navigate to.
<h1>Red to Violet</h1>
first .
second .
<div id="section">
<div class="innersections">
<a id="one" name="one"></a>
(text)
</div> <hr>
<div class="innersections">
<a id="two" name="two"></a>
(text)
</div></div>
If you wnat the h1 header to remain at the top, you can use position:fixed;top:0.
Here is a JSFiddle that illustrates this: http://jsfiddle.net/VZjdN/ (I've made some small changes to your HTML. If you don't want to use an HTML5 header tag, you can use a div.)
The full CSS is:
header {
position: fixed;
top: 0;
background: white;
width: 100%;
}
.innersections {
padding-top: 5em;
}
And the modified mark-up:
<body>
<header>
<h1>Red to Violet</h1>
first. second.
</header>
<div id="section">
<a name="one"></a>
<div class="innersections" style="padding-top:6em">
<h2>Inner 1</h2>
<div style="height:800px"></div> <!-- filler -->
</div>
<hr>
<a name="two"></a>
<div class="innersections" style="padding-top:4em">
<h2>Inner 2</h2>
<div style="height:800px"></div> <!-- filler -->
</div>
</div>
</body>
SOLVED
http://jsfiddle.net/GPRVX/
.section {
margin-top: 8em;
}
.fix {
height: 7em;
top:0; left: 0;
position: fixed;
background: white;
margin: 0;
padding: 0.5em;
width: 100%;
}
.innersections {
padding: 0.5em;
}
.section a:before {
display:block;
content:"";
height:8em;
margin:-8em 0 0;
}