I want to make the image 70% visible stick with the bottom and the rest of it invisible behind the div. I follow the tutorial with z-index 10 position absolute and overflow:hidden. but the image still show and overlap on other div. Could you help me? thanks!
HTML
<div class="screenshot search">
<div class="container container-fluid">
<div class="row">
<div class="col-md-6">
<img class="img-responsive" src="./img/sc-search#2.jpg" alt="pencarian"/>
</div>
<div class="col-md-6">
<h3>
search
</h3>
<p>
test
</p>
</div>
</div>
</div>
</div>
CSS
.screenshot {
padding: 6em 0;
height: auto;
}
.screenshot img {
width: 400px;
max-width: 90%;
z-index: 10;
position: relative;
overflow: hidden;
}
.search {
background-color: #fafafa;
}
There are loads of methods to do what you want if I understand right - (a screenshot would help, also if you are including "working code" include a JS fiddle or codepen link) then the example below has working overlap of your content div and the image.
<div class="screenshot search">
<div class="container container-fluid">
<div class="row">
<div class="wrap">
<div class="col-md-6 image-wrap">
<img class="img-responsive" src="http://www.navipedia.net/images/a/a9/Example.jpg" alt="pencarian"/>
</div>
<div class="col-md-6 content">
<h3>search</h3>
<p>test</p>
</div>
</div>
</div>
</div>
</div>
.screenshot {
padding: 6em 0;
height: auto;
}
.wrap {
position:relative;
}
.screenshot img {
width: 400px;
max-width: 90%;
z-index: ;
position: absolute;
}
.image-wrap {
overflow:hidden;
position:relative;
height: 200px;
}
.content {
display:block;
background:white;
position:absolute;
top:0;
width:100%;
}
.search {
background-color: #fafafa;
}
Fiddle
Read about Z-index here
Related
I have content navigation div overlapping menu navigation div. Please let me know what am i missing here. Please find fiddle link below:
https://jsfiddle.net/y4c2xs5j/1/
HTML:
<div class="top-nav">
<div class="menu-nav">
<div class="row">
<div class="col-md-12">
<span>Test</span>
</div>
</div>
</div>
<div class="content-nav">
<div class="row">
<div class="col-md-12">
<div>
<p>
Card content
</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div>
<p>
Card content
</p>
</div>
</div>
<div class="col-md-4">
<div>
<p>
Card content
</p>
</div>
</div>
</div>
</div>
</div>
CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: red;
height: 100vh;
}
.top-nav {
width: 100vw;
}
.menu-nav {
width:60px;
background: green;
height: 100vh;
float: left;
}
.content-nav {
width: calc(100vw - 60px);
background: yellow;
height: 100vh;
}
As per my understanding, you want to cover only 60px width with menu-nav, and rest want to cover with content-nav, According to below code:
.menu-nav {
width:60px;
background: green;
height: 100vh;
float: left;
}
.content-nav {
width: calc(100vw - 60px);
background: yellow;
height: 100vh;
}
If I am getting correct then you just neeed to add one more property with content-nav, overflow:hidden;
.menu-nav {
width:60px;
background: green;
height: 100vh;
float: left;
}
.content-nav {
width: calc(100vw - 60px);
background: yellow;
height: 100vh;
overflow:hidden;
}
By adding overflow hidden, you will get complete width rest 60px with content-nav, That is issue cause by float:left, when we are use float property, then the issue is generated, for the same we have to use overflow:hidden
Try this code. Is this what you needed ?
<div class="top-nav">
<div class="menu-nav">
<div class="row">
<div class="col-md-12">
<span>Test</span>
</div>
</div>
</div>
<div class="content-nav">
<div class="row">
<div class="col-md-12">
<div>
<p>
Card content
</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div>
<p>
Card content
</p>
</div>
</div>
<div class="col-md-4">
<div>
<p>
Card content
</p>
</div>
</div>
</div>
</div>
</div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: red;
height: 100vh;
}
.top-nav {
width: 100vw;
display: flex;
flex-direction: column;
}
.menu-nav {
width: 100vw;
background: green;
height: 20vh;
float: left;
}
.content-nav {
width: calc(100vw - 100px);
background: yellow;
height: 100vh;
}
You just need to add one property in ".content-nav" and also add clearifx class in the parent of both tag (.menu-nav, .content-nav)
<div class="top-nav clearfix">
.menu-nav {
width:60px;
background: green;
height: 100vh;
float: left;
}
.content-nav {
width: calc(100vw - 60px);
background: yellow;
height: 100vh;
float: left;
}
Whenever you use rows and columns, please check if you have at least one container that contains them. The gap you see on the right is caused by the negative margins from the rows.
The easy fix is to have .container-fluid on or inside menu and content nav.
On menu and content nav
<div class="top-nav">
<div class="menu-nav container-fluid">
...
</div>
<div class="content-nav container-fluid">
...
</div>
</div>
demo: https://jsfiddle.net/davidliang2008/x9d3bvLp/8/
Inside menu and content nav
<div class="top-nav">
<div class="menu-nav">
<div class="container-fluid">
...
</div>
</div>
<div class="content-nav">
<div class="container-fluid">
...
</div>
</div>
</div>
demo: https://jsfiddle.net/davidliang2008/x9d3bvLp/7/
You don't need to calculate the width for content-nav as fluid container will set its width to 100%:
.content-nav {
/*width: calc(100vw - 60px);*/
background: yellow;
height: 100vh;
}
<style type="text/css">
#displayHeader {
img {
width: 100%;
max-width: 100%;
max-height: 100%;
}
.header-img-inner {
max-height:100%;
}
}
</style>
<div id="displayHeader" style="height: 83.03px;">
<div class="header-inner">
<div class="row">
<div id="headerCol0" class="col-xs-4 text-center header-img-wrapper">
<div class="header-img-inner">
<img src="test.svg">
<p>TEST</p>
</div>
</div>
<div id="headerCol1" class="col-xs-4 text-center header-img-wrapper">
<div class="header-img-inner">
<img src="test.svg">
</div>
</div>
<div id="headerCol2" class="col-xs-4 text-center header-img-wrapper">
<div class="header-img-inner">
<img src="test.svg">
<p>tt</p>
</div>
</div>
</div>
</div>
</div>
<div id="displayContent" style="height: 264.8px;">
<div class="inner">
</div>
<div>
</div>
<div>
</div>
<div>
Image and text go out of the div block, why is this happening?
No float left, right used. It's not working with position:relative for parent and position absolute for child, but still not work well.
I only set maximum height for image when I set in on the header-img-inner
Why not use position: inherit; so as to make the image and whatever you want inside the div to inherit the position. This might help, give it a try.
Do you want something like this?
.block {
text-align: center;
background: #c0c0c0;
border: #a0a0a0 solid 1px;
margin: 20px;
}
.block:before {
content: '\200B';
/* content: '';
margin-left: -0.25em; */
display: inline-block;
height: 100%;
vertical-align: middle;
}
.centered {
display:inline-block;
vertical-align: middle;
width: 300px;
padding: 10px 15px;
border: #a0a0a0 solid 1px;
background: #f5f5f5;
}
<div class="block" style="height: 300px;">
<div class="centered">
<h1>Some Text</h1>
<img src="Untitled-2.jpg" height="150px">
</div>
</div>
Please check this link:-https://css-tricks.com/centering-in-the-unknown/
I'm trying to get the icon in the second wrapper div to cross up and dissect the previous wrapper div but the half that is supposed to appear in the div above will not appear. Even with a higher z-index. If I change the wrapper div overflow or position styles, it throws everything off. What is the correct way to do this? Here is the html and the css:
.wrapper {
position: relative;
width: 100%;
padding-bottom: 40px;
height: auto;
clear: left;
overflow: auto;
z-index: 1;
}
.process {
width: 100%;
height: 100%;
z-index: 1;
}
.process .icon {
position: relative;
height: 123px;
width: 123px;
margin-top: -60px;
border-radius: 50%;
z-index: 3;
}
<div class="wrapper">
<div class="page-heading">
<div class="col-md-6 col-centered">
</div>
</div>
</div>
<div class="wrapper blue">
<div class="process">
<div class="icon blue border-blue col-centered">
</div>
<div class="col-md-4 col-md-offset-1">
<div class="entry-content">
</div>
</div>
<div class="col-md-7 padding-right-100">
</div>
</div>
</div>
There is no table display necessary. What you need are actual heights for all elements - auto height won't work with no content, and 100% height only works if the parent container's height ( in this case body) is also defined. I made the body 100% and the two wrappers 50% .
The circle DIV has been centered horzontally with margin: 0 auto and pushed up using top: -60px while having: position: relative. The z-indexes remained unchanged 1 for the wrappers, 3 for the circle/icon (could also be 2).
There is also a codepen at http://codepen.io/anon/pen/KgNXmj
html, body {
height: 100%;
margin: 0;
}
.wrapper {
width: 100%;
height: 50%;
z-index: 1;
background: green;
}
.process {
width: 100%;
height: 100%;
z-index: 1;
background: blue;
}
.process .icon {
position: relative;
top: -60px;
margin: 0 auto;
height: 123px;
width: 123px;
background: #f00;
border-radius: 50%;
z-index: 3;
}
<div class="wrapper">
<div class="page-heading">
<div class="col-md-6 col-centered">
</div>
</div>
</div>
<div class="wrapper blue">
<div class="process">
<div class="icon blue border-blue col-centered">
</div>
<div class="col-md-4 col-md-offset-1">
<div class="entry-content">
</div>
</div>
<div class="col-md-7 padding-right-100">
</div>
</div>
</div>
After much research and hair-pulling, I found a solution that works. Not sure WHY, but the parent div had to have display:table and the child div display:table-row. If anyone knows why this works, definitely feel free to share.
I want to make a article preview, as you can see on nearly every shopsite.
My problem is the image inside the divs. The page should be responsive, that why the width and height of the divs are a percentage value. My question is now, how can I crop and center the image inside the divs?
Here is my code:
*{
margin: 0px;
padding: 0px;
}
.wrapper{
width: 100%;
}
.articlePreview{
display: inline-block;
width: 15%;
height: 15%;
max-width: 15%;
max-height: 15%;
margin: 1%;
padding: 1%;
background-color: orange;
}
<div class="wrapper">
<div class="articlePreview">
<div class="imgPreview">
<img class="img" src="http://lorempixel.com/500/200"/>
</div>
I'm a link
</div>
<div class="articlePreview">
<div class="imgPreview">
<img class="img" src="http://lorempixel.com/200/500"/>
</div>
I'm a link
</div>
<div class="articlePreview">
<div class="imgPreview">
<img class="img" src="http://lorempixel.com/100/100"/>
</div>
I'm a link
</div>
</div>
You could give each image the same height correspondent to the size of the viewing window. E.g. 10vh etc. in your css. This way all the images will remain the same height dependent upon the size of the window. You are using the classes you are setting on the divs but not the images themselves. If you use the class you added to the images you can specify the height, padding, etc.
For instance...
.img {
height: 10vh;
width: 10vh;
}
Now they all have the same size. It will distort the images if they are not square to begin with. It is a good place to start.
This should help
*{
margin: 0px;
padding: 0px;
}
body, html
{
width:100%;
height:100%;
}
.wrapper{
width: 100%;
height: 100%;
}
.articlePreview{
display: inline-block;
width: 15%;
height:15%;
max-width: 15%;
max-height:15%;
margin: 1%;
padding: 1%;
background-color: orange;
}
.imgPreview
{
width:100%;
height:80%;
}
.img
{
width:100%;
height:100%;
}
.imgTitle
{
width:100%;
height:20%;
font-size: 2vmax;
}
<div class="wrapper">
<div class="articlePreview">
<div class="imgPreview">
<img class="img" src="http://lorempixel.com/500/200"/>
</div>
<div class="imgTitle">
I'm a link
</div>
</div>
<div class="articlePreview">
<div class="imgPreview">
<img class="img" src="http://lorempixel.com/200/500"/>
</div>
<div class="imgTitle">
I'm a link
</div>
</div>
<div class="articlePreview">
<div class="imgPreview">
<img class="img" src="http://lorempixel.com/100/100"/>
</div>
<div class="imgTitle">
I'm a link
</div>
</div>
</div>
I have a fixed header and a image below the header.
The image has a property position: fixed.
Now for some devices the image is not in the center as It should be.
Here's the fiddle for it.
The left side has more spaces than the right hand side.
Also above the image, I want to add a p tag which is not showing up for some reason.
Please let me know what's wrong here.
<div class="content-wrapper new-class">
<div class="container">
<div class="row">
<div class="col-xs-12 ">
<div class="center-logo description">
<img src="http://i.imgur.com/ECTLTbK.png" alt="" class="img-responsive">
<P class="step1description" See price</p>
</div>
</div>
</div>
</div>
</div>
Checkout this solution:
body, html {
margin:0;
padding:0;
}
.content-wrapper {
position: relative;
overflow: hidden;
width: 100%;
background-color: #333230;
}
.content-wrapper .center-logo {
position: fixed;
width: 100%;
top: 125px;
left:0;
text-align: center;
margin: 5px 0 15px;
z-index: 1001;
background-color: #333230;
}
.content-wrapper .center-logo img {
margin: 0 auto;
}
.center-logo p.step1description {
position: relative;
top: -30px;
width: 220px;
text-align: center;
color: #fff;
font-size: 12px;
margin: 0 auto;
}
.description {
margin:30px 0 30px 0 !important;
}
.content-wrapper .content {
text-align: center;
width: 100%;
}
.new-class{
padding-bottom: 134px;
top: 134px;
}
<div class="content-wrapper new-class">
<div class="container">
<div class="row">
<div class="col-xs-12 ">
<div class="center-logo description">
<img src="http://i.imgur.com/ECTLTbK.png" alt="" class="img-responsive">
<p class="step1description"> See price</p>
</div>
</div>
</div>
</div>
</div>
You have some typos on html and css! - Here you can find a working fiddle: http://jsfiddle.net/sebastianbrosch/cxumhp9k/1/
Add left:0 on .content-wrapper .center-logo
.content-wrapper .center-logo { left:0;}