with a lot of trialnerror and grinding on stack, I (we) have managed to get two images to overlap in a very specific way:
This has been achieved like so:
.container {
width: 900px;
margin: auto;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.container_2 {
position: relative;
padding-top: 41.3%;
}
.imageContainer {
width: 70%;
position: absolute;
top: 0;
}
.psuedoContainer {
position: relative;
padding-top: 59%;
}
.psuedoHolder {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
img {
height: 100%;
width: auto;
}
<div class="centered">
<div class="container">
<div class="component">
<div class="container_2">
<div class="imageContainer" style="left: 0;">
<div class="psuedoContainer">
<div class="psuedoHolder" style="text-align: left;">
<img src="./img/img_codemesomething.png" />
<a href="page_appDev.html"/>
</div>
</div>
</div>
<div class="imageContainer" style="right: 0;">
<div class="psuedoContainer">
<div class="psuedoHolder" style="text-align: right;">
<img src="./img/img_recordmesomething.png" />
<a href="http://google.de"/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
And as you can see, there are two links included into the main two pictures (HTML).
However, only one of the two is working (the google one isnt). This is probably because one images is sort of "above" the other one, and therefore the lower one can never be clicked. At least it cannot be clicked just like it is right now.
How would I go on about adding a link to both images, that, wherever the user clicks, except for in the white part between both images, the user gets directed to a different page?
Thank you :)
you can wrap the images with the a tag
.container {
width: 900px;
margin: auto;
}
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.container_2 {
position: relative;
padding-top: 41.3%;
}
.imageContainer {
width: 70%;
position: absolute;
top: 0;
}
.psuedoContainer {
position: relative;
padding-top: 59%;
}
.psuedoHolder {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
img {
height: 100%;
width: auto;
}
<div class="centered">
<div class="container">
<div class="component">
<div class="container_2">
<div class="imageContainer" style="left: 0;">
<div class="psuedoContainer">
<div class="psuedoHolder" style="text-align: left;">
<a href="https://stackoverflow.com/questions/55650192/html-add-link-to-overlapping-images-pic/55650729#55650729"> <img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" />
</a>
</div>
</div>
</div>
<div class="imageContainer" style="right: 0;">
<div class="psuedoContainer">
<div class="psuedoHolder" style="text-align: right;">
<a href="https://stackoverflow.com/"> <img src="https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" />
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Related
I have 3 divs inside a section. The divs position is absolute because I want a really small gap between the 3 divs, but when I want to horizontal the divs nothing happens. What should I do?
#columnL {
width: 412px;
height: 705px;
position: absolute;
left: 0;
}
#columnM {
width: 412px;
height: 705px;
right: 0;
left: 0;
position: absolute;
}
#columnR {
width: 412px;
height: 705px;
position: absolute;
right: 0;
}
<section id="blabla">
<div id="columnL">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
<div id="columnM">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
<div id="columnR">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
</section>
Make a parent div with a relative positioning rule. Like this:
#blabla {
position: relative;
}
Indicate the margin: auto for each card - #columnL, #columnM and #columnR.
And push the width: 100% for the img tag. Like this:
img {
width: 100%;
}
But why do you need absolute positioning?
#blabla {
position: relative;
}
#columnL {
width: 412px;
height: 705px;
position: absolute;
left: 0;
margin: auto;
}
#columnM {
width: 412px;
height: 705px;
right: 0;
left: 0;
position: absolute;
margin: auto;
}
#columnR {
width: 412px;
height: 705px;
position: absolute;
right: 0;
margin: auto;
}
img {
width: 100%;
}
<section id="blabla">
<div id="columnL">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
<div id="columnM">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
<div id="columnR">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
</section>
Solution with flex and absolute positioning.
The absolute in this solution is an additional parent block, with a class of .absolute, as well as a flexible rule that sets the indentation by the gap rule.
#blabla {
position: relative;
}
.absolute {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: space-between;
gap: 30px;
}
#columnL {
width: 412px;
height: 705px;
}
#columnM {
width: 412px;
height: 705px;
}
#columnR {
width: 412px;
height: 705px;
}
img {
width: 100%;
}
<section id="blabla">
<div class="absolute">
<div id="columnL">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
<div id="columnM">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
<div id="columnR">
<div id="afbeeldingL">
<img src="https://www.spiralex.nl/wp-content/uploads/2021/01/110-14018-b-Petronas-V2017.jpg">
</div>
<div id="tekstL">
<h1 id="hoofdstuk1">TEXT</h1>
</div>
</div>
</div>
</section>
what is the HTML with CSS Code to align have logo and text in the same line...that it must look as shown in the below pattern..
HTML:
<div class="top_left">
<div class="header">
<img src="https://b.fastcompany.net/multisite_files/fastcompany/imagecache/inline-small/inline/2015/09/3050613-inline-i-2-googles-new-logo-copy.png" alt="logo"/> <br/>
</div>
<h2 id="site-title"><a>GOOGLE</a>
<div id="site-description">SEARCH ENGINE </div>
</h2>
</div>
You can use the following html/css combo:
/* CSS */
.container-div {
position: fixed;
top: 0px;
left: 0px;
width: 250px;
height: 150px;
}
.img-div {
display: inline-block;
position: relative;
width: 45%;
height: 100%;
overflow: hidden;
}
.img-div img {
position: absolute;
top: 0px;
left: 5%;
width: 90%;
height: 50%;
border: 1px solid red;
}
.img-placeholder {
position: absolute;
top: 7.5%;
left: 15%;
}
.text-div {
display: inline-block;
position: relative;
width: 50%;
height: 100%;
border: 1px solid green;
overflow: auto;
}
<!-- HTML -->
<div class="container-div">
<div class="img-div">
<img />
<p class="img-placeholder">
Image Goes Here
</p>
</div>
<div class="text-div">
<h2>
Texty-text
</h2>
<p>
Sub-texty-text
</p>
</div>
</div>
Use this code
<p><img src="https://cdn.pixabay.com/photo/2016/12/27/21/03/lone-tree-1934897_960_720.jpg" alt="imag" style="height: 50px;width: 50px;"><span>kiran</span></p>
hello try to make a container for the logo and the text and a few div with a float that would do the job if i am right
like this
<div class="name of class you made" //give jut a with>
<div class="logo" //put float in this with a with>logo</div><div class="tekst" //put float in this with a with>tekst</div>
</div>
i am not sure but this would help
You can either use (on the h4 elements, as they are block by default)
display: inline-block;
Or you can float the elements to the left/rght
float: left;
Just don't forget to clear the floats after
clear: left;
Try something like this
<div class="container">
<div id="logo">
<img src="http://placehold.it/150x100">
</div>
<div id="text">
<h2>Hello</h2>
<h3>World</h3>
</div>
</div>
CSS:
.container > div {
display: inline-block;
padding: 5px;
}
#logo, #text {
float: left;
}
Here's the fiddle
I have an issue with a sticky footer made with flexbox. It works well on resolutions upto 1366*768 but on 1600*1300 pixels the footer gets pushed to the bottom of the visible screen despite there being very little content.
Here is the html structure that I am using.
body , html {
height: 100%;
}
#main {
display: flex;
flex-direction: column;
min-height: 100vh;
}
#content {
flex: 1;
}
<body>
<div class="ui secondary pointing menu">
<a class="active item"><img src="/assets/images/ti.jpg" class="image ui small"></a>
<div class="right menu"><a class="ui item">Logout</a></div>
</div>
<div id="main">
<div id="content" class="ui container">
<div id="pie-menu" style="position: relative;">
<div class="DVSL-resize-triggers">
<div class="DVSL-expand-trigger">
<div style="width: 1128px; height: 501px;"></div>
</div>
<div class="DVSL-contract-trigger"></div>
</div>
<!--ZoomCharts 1.11.7-->
<div>
<div class="DVSL-background-container" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;">
<div class="DVSL-background" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;">
<div class="DVSL-background-image DVSL-PC-background-image" style="bottom: 0px; top: 92px; left: 405px; width: 317px; height: 317px; background-image: url(http://86.47.106.22:8080/assets/images/DublinPortCo.jpg);"></div>
</div>
</div>
<canvas class="DVSL-canvas" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; width: 1127px; height: 500px;" width="1127" height="500"></canvas>
<div class="DVSL-border" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;"></div>
<div class="DVSL-interaction" tabindex="0" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; cursor: default;">
<div class="DVSL-resizer" style="width: 1127px; left: 0px;"></div>
<div class="DVSL-info-left" style="position: absolute; display: none; left: 752px; top: 256px;"><b>Owl</b></div>
</div>
<div class="DVSL-menu-container DVSL-menu-workaround" style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; cursor: default;"><span class="DVSL-empty"> </span></div>
</div>
</div>
</div>
<div class="ui inverted vertical footer segment">
<div class="ui container">
<div class="ui grid">
<div class="twelve wide column">Thermtec 2016. All Rights Reserved</div>
<div class="three wide column"><img src="/assets/images/logoenigma.png" class="image ui small"></div>
</div>
</div>
</div>
</div>
</body>
The site is visible at http://86.47.106.22:8080/
Your header (ui secondary pointing menu) is taking some space while the #main div is 100% of viewport so that becomes [header height] + [viewport height] = footer pushed down
You can try to make the header 10% of viewport and content 90% of viewport to ensure consistency
.ui.secondary.menu {
...
height: 10%;
box-sizing: border-box;
margin-bottom: 0;
}
#main {
display: flex;
flex-direction: column;
height: 90%;
}
I'm having an issue figuring out how to center a <div> within a <div> that popped up after clicking a button.
Not my example, but similar. HTML:
<div class="popup">
<div class="options">
<div class="option">
<span id="1">1</span>
</div>
<div class="option">
<span id="2">2</span>
</div>
<div class="option">
<span id="3">3</span>
</div>
<div class="option">
<span id="4">4</span>
</div>
</div>
<p></p>
<div id="persona">
<span id="5">5</span>
</div>
</div>
CSS:
.popup
{
background-color: #e3ddd1;
position: absolute;
left: 10%;
top: 10%;
height: 400px;
width: 500px;
}
#persona
{
margin-left: auto;
margin-right: auto;
}
The overlay is just used to fade out the background, and then the popup appears on top of it.
The issue is in the #persona block, how do I get it so that <div id="persona"> is centered within the popup?
Try this CSS. Working Demo
.overlay
{
background-color: rgba(0, 0, 0, 0.8);
display: block;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
}
.popup
{
background-color: #e3ddd1;
display: table;
position: absolute;
left: 50%;
top: 50%;
margin-left: -500px;
margin-top: -200px;
height: 400px;
width: 1000px;
}
#persona
{
display: table-cell;
margin-left: auto;
margin-right: auto;
text-align: center;
vertical-align: middle;
}
I am not able to vertically align middle some text using the position absolute method.
JSFIDDLE
HTML
<div class="heighted">
<div class="middle-wrapper">
<span class="middle">text to be vertically aligned in the middle</span>
</div>
</div>
<hr/>
<div class="heighted">
<div class="middle-wrapper">
<img class="middle" src="http://www.google.com/homepage/images/google_favicon_64.png" />
</div>
</div>
CSS
.heighted {
background: gray;
height: 100px;
}
.middle-wrapper {
height: 100%;
position: relative;
}
.middle {
bottom: 0;
margin: auto;
position: absolute;
top: 0;
}
I am getting Stack Overflow error when adding code, it might be a bug in Stack Overflow, so please follow the link.
Set line-height: 100px; to .heighted or .middle-wrapper or .middle - DEMO
CSS:
.heighted {
background: gray;
height: 100px;
line-height: 100px;
}
.middle-wrapper {
height: 100%;
position: relative;
}
.middle {
bottom: 0;
margin: auto;
position: absolute;
top: 0;
}
HTML:
<div class="heighted">
<div class="middle-wrapper">
<span class="middle">text to be vertically aligned in the middle</span>
</div>
</div>
<hr/>
<div class="heighted">
<div class="middle-wrapper">
<img class="middle" src="http://www.google.com/homepage/images/google_favicon_64.png" />
</div>
</div>
You should try display:table-cell; and use vertical-align:middle;
Check how amazing and optimize:
http://jsfiddle.net/9jugdtqx/2/
and:
http://jsfiddle.net/9jugdtqx/3/