I have made a website in bootstrap but struggling with a height issue, on two columns.
On the contact page there is two columns below the map. The left is an image and right is some text, would love it if someone could help me get it so they respond at the same height. So the left and right column resize the same way before snapping to full width.
http://reraisedesign.com/contact-us.php
<div class="container-fluid" style="padding: 0; background: #fff;">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-6 con-img">
<img src="img/contact-us.jpg" width="100%"/>
</div>
<div class="col-xs-12 col-sm-12 col-md-6 con-blurb">
<div class="row">
<div class="col-xs-10 col-xs-offset-1">
<h1>Say Hello</h1>
<span class="line-left"></span>
<p>We would like to just thank you for taking the time to visit our site, if you would like hear more about ReRaise feel free to give us a call or drop us an email. We would love to hear about any potential projects or queries you may have and will always aim to respond the same day.</p>
<p class="con-dets">0151 705 3414</br>
Send us an Email</p>
</div>
</div>
</div>
</div>
Here is the CSS to accompany the HTML
.con-blurb{
padding-top:100px;
padding-bottom:100px;
}
.con-img{
size:cover;
-webkit-size: cover;
-moz-size: cover;
-o-size: cover;
height: 100%;
}
.con-blurb h1{
text-align: left;
}
Try out this code:
.con-img img{
height: 100%;
max-width: 100%;
width: auto;
}
set the top margin property in .con-img class to margin-top:27px and set div including "say hello" margin-top:-106px
//code
.con-img{
margin-top:27px;
}
//div incluing say hello
.div{
margin-top:-106px;
}
Found a solution that didn't distort:
.con-blurb{
padding-top:100px;
}
.con-img img{
display: block;
max-width: 100vw;
background-size: cover;
height: 50vh;
object-fit: cover;
}
Related
I am trying to build an image-focussed page, where all images resize flexibly within fixed-sized containers. The containers are set up in two rows; the first are three 4-spaced columns each with an image (following bootstrap), and the second row is a 12-spaced column, filled with one image.
Ideally, I want them to show this behavior:
- If they are wider than the container, I want the image to be resized and centered, until the image border meets the container either heightwise or widthwise. Any corresponding spillover will be cut-off.
Overflow already cuts them off; align-self should center them; object-fit covers the image; but I don't know how to make it behave the way as I described above.
Thanks very much for having read this far, and thank you even more if you are willing to help me out ^^
The website
Code:
.img-responsive {
width: auto;
margin-left: auto;
margin-right: auto;
display: block;
position: relative;
align-self: center;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
object-fit: cover;
}
.col-4 {
min-height: 20px;
max-height: 300px;
padding: 0;
overflow: hidden;
}
.col-12 {
min-height: 150px;
max-height: 300px;
padding: 0;
overflow: hidden;
}
<section>
<div class="container-fluid">
<div class="row">
<div class="col-4 hoveropacity">
<img class="img-responsive" src="https://vietnamtravel.guide/wp-content/uploads/2015/04/Banh-Mi-Vietnam.jpg" );>
</div>
<div class="col-4 hoveropacity">
<img class="img-responsive" src="https://s.iha.com/00125194526/Hanoi-municipality-Street-market-in-hanoi.jpeg" );>
</div>
<div class="col-4 hoveropacity">
<img class="img-responsive" src="https://i.pinimg.com/736x/da/86/35/da863581a7524e3260b6ba75a8b08cdb--vietnamese-iced-coffee-coffee-latte.jpg" );>
</div>
</div>
</div>
</section>
<section>
<div class="container-fluid">
<div class="row">
<div class="col-12 hoveropacity">
<img class="img-responsive" src="https://www.vietnamtravelblog.info/wp-content/uploads/2011/05/Vietnam.jpg" );>
</div>
</div>
</div>
</section>
NB: I did look around for answers already given, but I couldn't quite find an answer that worked for me. Please forgive any oversight on my part.
Solved! Thanks to #Kangouroops
Added
object-fit: contain;
width: 100%;
height: 100%;
I'm using Bootstrap and am using the class col-md-6. On the left column I have an image and on the right column I have two paragraphs of text. When I shrink the web browser (or use mobile), I want the div to expand, instead of using a scroll bar. What ends up happening now is the image shows up fine but I have to use the scroll bar to see the paragraphs of text.
Sorry I'm kind of new to web programming and have spent a considerable amount of time trying to figure out what I'm doing wrong. Not sure if it's relevant but I'm also including the next chunk of code after the issue.
I want it to scroll from pg4 to pg5, but i don't want an additional scrollbar to have to see all the content in pg4.
EDIT: Also feel like I should note that I've seen similar questions posted here and have tried numerous of the answers to these issues and nothing has worked yet.
<div id="pg4">
<div class="container">
<h1 class="text-center text-uppercase">About Me</h1><hr/>
<div class="row">
<div class="col-md-6">
<img src="IMAGE" class="center-block img-responsive" id="picture" alt="Picture" />
</div>
<div class="col-md-6">
<p>PARAGRAPH 1</p>
<p>PARAGRAPH 2</p>
</div>
</div>
</div>
</div>
<div id="pg5">
</div>
/* PG 4 */
#pg4 {
background-color: #282E34;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
width: 100%;
height: 100%;
position: absolute;
display: block;
top: 250%;
overflow: auto;
}
#pg4 p {
color: white;
text-align: left;
font-size: 20px;
margin-left: 3%;
margin-right: 5%;
margin-bottom: 10%;
color: #6c6d6e;
}
#p1 {
margin-top: 15%;
}
#picture {
width: 45%;
margin-top: 15%;
}
/* PG 5 */
#pg5 {
background-image: url("IMAGE");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
height: 100%;
width: 100%;
position: absolute;
top: 350%;
overflow: auto;
}
Try to add additional classes to your divs
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-6 col-lg-6">
<img src="IMAGE" class="center-block img-responsive" id="picture" alt="Picture" />
</div>
<div class="col-md-6 col-sm-6 col-xs-6 col-lg-6">
<p>PARAGRAPH 1</p>
<p>PARAGRAPH 2</p>
</div>
</div>
Something like this.
If you do not specify col-xs-? by default bootstrap stacked your divs and it behaves like col-xs-12. Same for large displays. So you need to specify a width for extra small and large displays
And from that part:
#picture {
width: 45%;
margin-top: 15%;
}
remove width: 45% you already defined img-responsive
When you set height and overflow: auto for an element, It means you want this element to be scrollable. If you don't want this, instead of height: 100% set height: auto;
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>
As seen in the below screenshot
the viewport height is covered around 97% and not 100%. the next section can be seen. I am stuck with this issue for a couple of hours now, below is my css and html code
css
html, body {
width: 100%;
height: 100%;
}
.section-3 {
background: url(../images/section-3-bg.jpg) center center;
background-size: cover;
position: relative;
height:100vh;
}
HTML
<section class="section-3 col-xs-12" id="demand">
<section class="container">
<center>
<div id="trapezium"></div>
<h1 class="blue big-font">On Demand Charters</h1>
<img src="images/demand-border.png" alt="" class="img-responsive" style="width:auto;">
<div class="col-md-7 col-md-push-2">
<p class="medium-font">With Powerfly, access a range of aircraft from light
to large jets, turboprops and helicopters
either through on-demand charters. All you need to
do is book and a Powerfly executive will customise
your plan as per your needs.
</p>
<h2 class="explore-btn">Details</h2>
</div>
</center>
</section>
</section>
The real problem is the carousel!
#carousel-generic-1 {
margin-top: 0;
}
It works fine .. You didn't take a complete screenshot of the section but it actually take the place it should.
However, it cuts the button because of the height: 100vh;
I'm using Bootstrap to create my animation portfolio and currently have my sticky header working, but don't know how to fix two issues with it. You can see a working example [here].
Center the header exactly above the content div (right now it has a small offset to it)
Scale header to always take up 10% of the browser vertical size
(optional) Would like the content div to start exactly where the header stops so nothing gets cut off
Here is what my code looks like:
HTML
<div class="container">
<div class="affix affix-top header-resize" style="position: top; margin: 0 auto; clear: left; height: auto; z-index: 5; text-align: center; background-size: cover; background-color: clear;">
<div class="container" style="background-image: url('img/header-bg.png'); background-size: cover; height: auto;">
<img src="img/logo.png" class="col-xs-8" alt="Jesse J. Jones - Animator/Illustrator/Designer">
</div>
<div class="container" style="background-image: url('img/header-gradient.png'); background-repeat:repeat-x; background-size: cover; height: 20%;">
</div>
</div>
</div>
CSS
.header-resize {
height: 10%;
}
Thank you for your help! I'm pretty new to Bootstrap and responsive design, so all this is purely me experimenting and following tutorials. Let me know if I need to explain anything further! :)
Thank you,
Jesse
You forgot to add bootstrap's own ROW div. This will re-center your header:
<div class="container">
<div class="row">
<div class="affix affix-top header-resize" style="position: top; margin: 0 auto; clear: left; height: auto; z-index: 5; text-align: center; background-size: cover; background-color: clear;">
<div class="container" style="background-image: url('img/header-bg.png'); background-size: cover; height: auto;">
<img src="img/logo.png" class="col-xs-8" alt="Jesse J. Jones - Animator/Illustrator/Designer">
</div>
<div class="container" style="background-image: url('img/header-gradient.png'); background-repeat:repeat-x; background-size: cover; height: 20%;"></div>
</div>
</div>
</div>