How to make image between two grid dives? That image would be 50% on one and 50% on another?
<div class="row">
<div class="col-lg-12">
</div>
</div>
<div class="sec-div">
<img class="img-fluid img-second "src="http://lorempixel.com/400/200/cats">
</div>
<div class="row">
<div class="col-lg-12 second">
</div>
</div>
I think you should use z-index to keep the img below - not sure if will be necessary, set the body { background-color: gray } and set the margin of the main div with a negative value. I think this will work.
Try this: (I'm assuming you're using Bootstrap)
HTML:
<div class="container-fluid" id="header"></div>
<div class="container second">
<div class="col-lg-12 ">
</div>
</div>
CSS:
#header {
padding: 2% 0% 5% 0%; /* you should control img height through here, as width will be viewport sized */
background: url('images/pool.jpg');
background-attachment: static;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
z-index: 0 /* try using this to set this div below the other */
}
.second {
margin: /* negative value */
z-index: /* bootstrap items have really high numbers, so I guess this won't be necessary */
}
See it working here! https://jsfiddle.net/hokumi/m7qoy7h3/
Related
I have a problem adding the background-image: url() tag to my code. It doesn't display. I've tried everything, added strings, made it the first in the block but nothing works. Quite frustrating.
The HTML:
<div id="home" class="offset">
<div class="landing">
<div class="home-wrap">
<div class="home-inner"></div>
</div>
</div>
The CSS:
.home-inner {
background-image: url("imgs\04-full.jpg");
position: relative;
background-size: cover;
}
This is happening becouse the div with the background-image attribute has no sizes so it is displayed in the html page but it has width and heght null.
.home-inner {
background-image: url(https://www.gravatar.com/avatar/062021b6a1aae23a9651e9ab01ec9e36?s=48&d=identicon&r=PG&f=1);
position: relative;
background-size: cover;
width: 500px; /* fixed width */
height: 500px; /* fixed height */
}
<div id="home" class="offset">
<div class="landing">
<div class="home-wrap">
<div class="home-inner"></div>
</div>
</div>
Try adding some content to it or giving the div some width and height
I'm working on a small site for a startup
the site works well on desktops, but I'm trying to make it more responsive
using the Bootstrap grid system, however I'm getting red grid lines
What am I doing wrong?
Screenshot
HTML and CSS code below
<section class="tds-banner">
<div class="overlay">
<div class="description">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12">
<h1>Fishing Club Studios</h1>
</div>
</div>
<div class="row">
<div class="col--xs-12 col-sm-12">
<h5>We Make food and We drinks</h5>
</div>
</div>
<div class="row">
<div class="col-6">
Food
</div>
<div class="col-6">
Drinks
</div>
</div>
</div>
</div>
</section>
<style>
<!--CSS-->
#media only screen and (min-device-width: 300px) {
.tds-banner .overlay{
position: absolute;
min-height: 100%;
min-width: 100%;
left: 0;
top: 0;
background-image:url('/static /talking_drumstudios_logo_360.png');
background-attachment: fixed;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
.description {
font-size: 20px;
border: none
}
}
</style>
When you find this kind of issues with borders using frameworks to override, inspect the element and try properties like:
border: none;
box-shadow: none;
outline: none;
About your text issues, I don't have access to your code but you probably have:
Reduce the padding on the container or margin on the divs, that's
why you have all this white space on top and left.
Or I see that you're using position absolute in some cases, try using to the minimum otherwise you'll have more work trying to do the responsiveness.
From your screenshot, it seems like you have assigned border to row or column class, try this CSS code:
.row,col-*{
border-width:0px;
}
My code is here: JSFiddle (I am working with Bootstrap 3)
Basically, my problem is I can't get the images in the columns to keep their aspect ratio, probably because the column height is fixed.
If I remove:
img {
width: 100%;
height:100%;
}
the images simply get cropped...
The column size is fixed, because I want the entire body of the page to fit the window vertically and have no scroll bar, since I am working on a desktop application and the only solution I found is to define everything in Viewport units.
I'm not sure I'm even on the right track, trying to define everything in vh/vw? Maybe there is another way?
This is very roughly speaking (or drawing..) what I want to achieve in the end: Layout
Any input at all would be greatly appreciated.
Use divs instead if img-tags and give them the image src as a background url. You can then set background-size to contain of cover.
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
html, body{
height:100vh;
overflow:hidden;
}
.container-fluid {
height: 80vh;
width: 90vw;
overflow-y:hidden;
}
.col-lg-6 {
height: 32vh;
overflow:hidden;
}
.col-md-6 {
height: 32vh;
overflow:hidden;
}
.col-s-6 {
height: 32vh;
overflow:hidden;
}
img {
width: 100%;
height:100%;
}
#img-1 {
background: url(http://farm5.staticflickr.com/4149/5174348786_e4a8494137.jpg) center center no-repeat;
background-size: contain;
height: 100%;
}
#img-2 {
background: url(http://noliesradio.org/wp/wp-content/uploads/2014/02/introslide.JPG_.jpg) center center no-repeat;
background-size: cover;
height: 100%;
}
<div class="container-fluid">
<div class="row">
<div class="row">
<div class="col-lg-6 col-md-6 col-s-6">
<div id="img-1" src="http://farm5.staticflickr.com/4149/5174348786_e4a8494137.jpg">
</div>
</div>
<div class="col-lg-6 col-md-6 col-s-6">
<div id="img-2">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-s-6">
<img src="http://www-static.weddingbee.com/pics/52547/jacaranda.jpg">
</div>
<div class="col-lg-6 col-md-6">
<img src="http://www.paramountplants.co.uk/images/evergreen-screening/acer-palmatum-dissectum-garnet-specimen-tree.jpg">
</div>
</div>
</div>
I have a page in which I am using bootstrap for designing. Now I am using grids; I want to keep 8 columns for my image and 4 columns for the text. So i have following code:-
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="bg"></div>
</div>
<div class="col-md-4">
hi how are you
</div>
</div>
</div>
Following is the css for class bg :
.bg {
background-image: url('../images/2.jpg');
background-repeat: no-repeat;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height:690px;
}
Now everything works fine, but I am facing a small problem here where i am checking this in extra small screen, the picture occupies almost the entire screen and for text i have to scroll way to the bottom.
Is there any way to adjust image height(width works perfectly fine) for extra small screens so that image and text can be seen together without much scrolling?
Try using viewport-height in CSS3:
.bg {
height:100vh;
}
do like this.give div class name as img-responsive and set width and height as your need.and put your image inside it and set its width and height like this.
<div class="img-responsive" style="width: 300px;height: 300px;">
<img style="width: 100%;height: 100%" src="http://www.intrawallpaper.com/static/images/1250654-for-laptop-nature.jpg"/>
</div>
if you want text over picture, you can do this:
#media (max-width: 480px) {
.bg {
position: absolute;
left: 0;
width: 100%;
}
}
if you want half top is picture, half bottom is text, you can do this:
html
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="wrap">
<div class="bg"></div>
</div>
</div>
<div class="col-md-4">
hi how are you
</div>
</div>
</div>
css
#media (max-width: 480px) {
.wrap {
position: relative;
padding-bottom: 50%;
}
.bg {
position: absolute;
left: 0;
width: 100%;
height: 100%;
}
}
hope it can help
I have a question that I suspect has a simple answer. I'm using Bootstrap to make a personal webpage, and I'm attempting to divide the background into 3 equal columns (which will all have different images).
I know this could be done with class="col-xs-4" but the issue is that I'd like to keep what's over the background as-is (it's a "col-lg-12" that is responsive).
Is there a way to split my background (again, going to upload images into the 3 panels, and the panels will essentially mask the full images), and still have all the "col-lg-12" heading stuff on top?
Thanks for any help you can give, my current html code is such:
<header>
<div class="container">
<div class="row">
<div class="col-lg-12">
<img class="img-responsive" src="img/picture.png" alt="">
<div class="intro-text">
<span class="intohead">Filler Text</span>
<span class="subhead">More detailed, longer filler text for below</span>
</div>
</div>
</div>
</div>
</header>
Basically, there are three columns with background images, and then a cover div that is placed on top of the three columns. You can place anything you like in the cover div. Here's an article about CSS positioning.
.wrap {
width: 100%;
height: 300px;
position:relative;
}
.section {
float: left;
height: 300px;
width: 33.33333%;
}
.one {
background: url(http://placehold.it/200x300/ccc/666/&text=img+1) no-repeat;
background-size: 100%;
}
.two {
background: url(http://placehold.it/200x300/666/ccc/&text=img+2) no-repeat;
background-size: 100%;
}
.three {
background: url(http://placehold.it/200x300/ccc/666/&text=img+3) no-repeat;
background-size: 100%;
}
.cover {
width: 100%;
height: 100%;
/*A background isn't needed, it's just to show that the element is there*/
background: salmon;
opacity: .5;
/* this stuff is key */
position: absolute;
top: 0;
left: 0;
/* place cover on top */
z-index: 10;
}
<div class="wrap">
<div class="cover">Put all you content in here</div>
<div class="section one"></div>
<div class="section two"></div>
<div class="section three"></div>
</div>
Run the code snippet and tell me what happens. Is this what you're looking for?