Currently learning html by way of coding cool sites I find online. I'm having some trouble figuring out how this site http://sociali.st uses one image for the iPhone case and another image for the iPhone screen (think clipping masks in photoshop). Can't seem to get my head around it?
Here's my code
<div class="row">
<div class="small-6 columns">
<h1 class="value-prop">Organize the <br>things you love.</h1>
</div>
<div class="small-6 columns">
<div class="phone">
<img src="http://sociali.st/wp-content/themes/socialist/library
/images/views/home/home-introduction-screen.png">
</div>
</div>
</div>
CSS
.phone {
width: 359px;
height: 935px;
background-image: url('http://sociali.st/wp-content/themes/socialist/
library/images/components/devices/device-iphone
-5c-perspective-left-shell#2x.png?cache=290611593');
background-size: 100% 100%;
}
The magic is done using absolute positioning and transparent backgrounds, more like photoshop layers.
Check this:
http://codepen.io/anon/pen/dGxhy
Use position: relative in the .phone so we can position its child elements based on its own top/left.
The #phone-content is already above the phone chrome due to the standard stacking order.
Then using the position, top and left properties we can move the content layer to match the desired placeholder
Raed some articles (example http://css-tricks.com/almanac/properties/p/position/) related to the css position attributes and it will be very clear to you ;)
There are many ways to do this, the easiest is probably using absolute positioning:
<div class="row">
<div class="small-6 columns">
<h1 class="value-prop">Organize the <br>things you love.</h1>
</div>
<div class="small-6 columns">
<div class="phone">
<img src="http://sociali.st/wp-content/themes/socialist/library/images/views/home/home-introduction-screen.png">
</div>
</div>
</div>
And css:
.phone {
position:relative;
width: 359px;
height: 935px;
background-image: url('http://sociali.st/wp-content/themes/socialist/library/images/components/devices/device-iphone-5c-perspective-left-shell#2x.png?cache=290611593');
background-size: 100% 100%;
}
.phone img{
top:130px;
position:absolute;
width:285px;
left:25px;
}
I added position:relative; to .phone because we are using the position:absolute; method.
Then, I just placed it to look like the screen.
Related
How to positioning the elements one under the other, regardless of the height of the item? As having the following markup, to place the elements in the following way:
.photo {
display: inline-block;
vertical-align: top;
max-width: 160px;
width: 100%;
margin: 0px 20px 20px 0;
background:red;
}
<div class="photo">
<div class="photo__item photo__item_1"></div>
</div>
<div class="photo">
<div class="photo__item photo__item_2"></div>
</div>
<div class="photo">
<div class="photo__item photo__item_3"></div>
</div>
<div class="photo">
<div class="photo__item photo__item_4"></div>
</div>
<div class="photo">
<div class="photo__item photo__item_5"></div>
</div>
<div class="photo">
<div class="photo__item photo__item_6"></div>
</div>
There are a couple of ways of doing this.
Emulate this effect by using the css column property, I found this fiddle for example, you can see how the elements are positioned.
Other way (most viable I think) is to use a plugin like masonry as #kukkuz said before, it does almost everything you need.
Create your own grid using javascript and css in order to position every element based on other element's positions (which I wouldn't recommend) because you have to do some calcs and it could take some time.
Need to place images kinda like here (for example): http://imgur.com/QpRjvpW
Original pictures of different sizes.
Hover effect - blur and fogging effects and text on the middle of the picture.
Here is what I got for now: JSFiddle
So the question, how correctly position them, so that they occupy the entire width of the screen by 3 in a row, gonna be same size, closely adhering to the upper and lower div and to each other, don't expand within its borders? And the effect of the blur doesn't touch neighboring elements?
Remove class row and col-lg-12,use col-sm-12 like
<div class="col-sm-12">
<div id="work1" class="col-sm-4">
<img class="image" src="http://i.telegraph.co.uk/multimedia/archive/03257/POTD-SKY-SQUIRREL_3257854k.jpg">
<p class="text">ONE</p>
</div>
<div id="work2" class="col-sm-4">
<img class="image" src="http://i.telegraph.co.uk/multimedia/archive/03235/potd-husky_3235255k.jpg">
<p class="text">TWO</p>
</div>
<div id="work3" class="col-sm-4">
<img class="image" src="http://s.hswstatic.com/gif/dolphin-pictures-1.jpg">
<p class="text">THREE</p>
</div>
</div>
CSS:
works img {
height: 600px;
width: 100%;}
Apply this css, you'll get the look like the example --
.works img{
display:block;
max-width:100%;
}
.works [class^="col-"] {
padding-left:0;
padding-right:0;
}
.works .text{
position:absolute !important;
left: 0;
right: 0;
}
I'm working on a Bootstrap page for the first time. Used to working in HTML/CSS and all just not bootstrap. I'm having some difficulty with the following:
I created a fluid ( full width ) container that spans 4 columns.
The 1st column contains an image, the 2nd text, the 3rd an image and the 4th text again. The next row of columns is alternating.
I want my columns to have a responsive width and height so that if i adjust the viewport, the colums are always squared and stretching the full page. I just can't seem to get this to work. Tried various things. Setting max width, using percentages, background images, img scr tags that scale to 100% etc. but nothing seems to work.
Can anyone tell me how i can make this happen?
Greatly appreciated. No problem if JS or JQuery is needed to make it work. I got the basics covered so i know how to do that if someone points me in the right direction ( not a JS wizard to figure this one out on my own just yet ).
For example, i provided my HTML markup.
The CSS is pretty basic. Just provided the background images in the ft-img columns and some styling for the fonts. Also, currently all col have a fixed height of 400 pixels but that is abviously not the way to go. :P
<div class="container-fluid main-content">
<div class="row">
<div class="col-md-3 ft-img ft-1">
</div>
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
<div class="col-md-3 ft-img ft-2">
</div>
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
</div>
<div class="row">
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
<div class="col-md-3 ft-img ft-1">
</div>
<div class="col-md-3 ft-text">
<h1>Heading</h1>
<hr>
<p>Paragraph </p>
</div>
<div class="col-md-3 ft-img ft-2">
</div>
</div>
</div>
As asked, here's the CSS. I initially did not provide it since it's just the basics and it's just one of the things i tried. As said above.
.ft-img {
background-size: 100%;
background-position: center center;
height: 400px;
}
.ft-text {
background: url('../img/bg.png');
background-position: 10% 10%;
height: 400px;
color: #fff;
font-family: 'Lato', sans-serif;
padding: 40px;
}
.ft-text h1 {
font-size: 2.5em;
font-weight: bold;
}
.ft-text p {
font-size: 1.2em;
}
.ft-1 {
background: url('../img/ft/ft-1.jpg') no-repeat;
}
.ft-2 {
background: url('../img/ft/ft-2.jpg') no-repeat;
}
If you want to be fluid, you can't specify fixed units (px).
Consider using the vw unit to make your heights relative to their widths to maintain squares.
http://www.w3.org/TR/css3-values/#viewport-relative-lengths
I've the following markup for a page which is mobile ready:
<section>
<div class="cover-section">
<img src="img/central-park.jpg" alt="" style="width:100%" class="hoverZoomLink">
</div>
<div class="logo-section">
<div class="container postLeft hiddenClass visibleClass animated fadeInLeft">
<img src="img/logos/instagram.png" alt="">
</div>
</div>
</section>
The problem is, since I provided width:100% for the imgin the mobile view, the whole image is appeared to be proportionate and as a result, very small. (Since this image is very wide).
Is there any way that I can display the image with a min-height:300px without adding the image as a background and make it as cover ? Because the image is being generated dynamically in which case allocating it to a particular css class wouldn't be easy.
There's no other better way around this:
img{/*but target to specific selector that you need*/
min-height: 300px;
max-width: 100%;
}
This produce the responsive result but when minimum height fits the requirement then this starts stretching.
One better solution is to use image as background and using css like this produce better experience with responsive image:
.cover-section{/*remove img inside this selector to use it as background*/
background: url(image-path.jpg) no-repeat center;
background-size: cover;/*don't forget to use vendor prefixes*/
min-height: 300px;
max-width: 100%;
}
You could always use media queries to handle CSS for mobile devices. Something like follows : (I've moved your img styling to a class 'cover')
.cover {
width:100%;
}
#media screen and (max-width: 500px) {
.cover {
min-height: 300px;
}
}
</style>
<section>
<div class="cover-section">
<img src="img/central-park.jpg" alt="" class="cover hoverZoomLink">
</div>
<div class="logo-section">
<div class="container postLeft hiddenClass visibleClass animated fadeInLeft">
<img src="img/logos/instagram.png" alt="">
</div>
</div>
</section>
Not sure if this is what you want.
hi I have two container divs one of them has a div with an image background and i think this is the div that is causing problem. I tried removing both container divs and the gap was still here. there are no margins no paddings, and i know it is not the image that has this line its not there when i open it in photoshop. I am also using css reset
Where is this space coming from?
css
.container{
width:100%;
}
.container2{
width:100%;
}
.first-image{
width:1430px;
height:497px;
background-image:url('../images/introimg.jpg');
background-repeat:no-repeat;
background-size: 100%;
border:none;
}
.jamey{
width:35%;
}
.second-image{
width:1430px;
height:430px;
background-image:url('../images/secondimg.jpg');
background-repeat:no-repeat;
background-size: 100%;
}
html
<div class="container">
<div class="wrapper">
<div id="overlay"></div>
<div class="first-image">
<div class="jamey">
<p class="def">
JAMEY
</p>
<p class="rip-date">03.02.1997 - 09.18.2011</p>
<p class="def2">Anonymous hate messages were posted on his Formspring account including one that claimed:</p>
</div>
</div>
</div>
</div>
<div class="container2">
<div class="intro-div">
<div class="end-hate">
<h1>PUT AN END TO HATE.</h1>
<p>
ANYTHING WRITTEN ONLINE can become viral
</p>
<p>
We believe that the way we behave online should be no different from the way that we behave in
</p>
<button type="button">JOIN CAMPAIGN</button>
</div>
</div>
Your problem can be removed by,
.first-image
{
margin-bottom: -20px; // or desired settings !
}
You may try adding the
box-sizing: border-box;
It helps setting padding/borders (maybe you have one) internal to the element. If it has some effect you can override these settings later.
Anyway, it's recommended that you add a jsFiddle so we can see for ourselves.