I have created a header div as follows:
<div class="header">
<div class="row">
<div class="col-lg-2 col-sm-2 col-xs-2 col-md-2">
<img class="img-responsive" src="logo.png"/>
</div>
</div>
</div>
Here is the header class:
.header {
background-color: #5DBCD2;
height: 10%;
}
Even though the div's max height is restricted to 10%, the image exceeds this.
Can someone please help
Add the following to your CSS so that you can have the image contained within the div nicely as it scales down.
.header img {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
}
You can also add overflow: hidden; to the header element but that will cut it off rather than scale it, but it is another potential option.
I am not sure if it will be to any help, but try to add a max-height to the image in CSS.
EDIT
You could add this in the CSS (so that the image has 10% of the width of the parent):
.img-responsive {
width: 10%;
}
I tried your code with an image of 2000 x 1522 pixel dimensions.
Worked fine.
Few things you can do:
1) Debug your page using Developer tools in the browser.
2) Check if your css file path is correct.
3) Check for any errors in console part of the developer tools.
In your above code bootstrap before declaring row you must first declare container you should have something like this below
<div class="header">
<div class="container">
<div class="row">
<div class="col-lg-2 col-sm-2 col-xs-2 col-md-2">
<img class="img-responsive" src="logo.png"/>
</div>
</div>
</div>
</div>
Probably this should work
Related
I build a small app using Bootstrap 5. There are 10 columns col-lg-10 on the left and 2 columns col-lg-2 on the right on the desktop view. The canvas clock is to be located in the centre of the most right columns. At the moment the clock is not centred and any CSS I apply does not seem to work. Please see the HTML code:
'''
<section>
<div class="container-fluid">
<div class="row">
<div class="col-lg-10 col-md-6 col-sm-12">
</div>
<div class="col-lg-2 col-md-6 col-sm-12 mx-auto">
<!-- analog clock location -->
<div id="clockContainer">
<canvas id="analogClock"></canvas>
</div>
</div>
</div>
</div>
</section>
'''
I tried to centre the canvas clock using bootstrap classes. The class="mx-auto" class was applied on the div with an id="clockContainer". But this does seem to solve the problem.
Later, I linked the CSS file and tried to do the following (non of the below solution worked):
#clockContainer{
margin: auto;
width: 250px;
}
#analogClock{
width: 250px;
}
I tried also:
#clockContainer{
width: 250px;
margin: auto;
}
Any hints on how to resolve it?
Thanks!
I'm a backend guy and trying to figure out a few details for a project we have that's using Bootstrap 4.
Simply put, we want to create the layout that's executed here:
https://codepen.io/mediumandmessage/pen/xVeXop
(this example and the code below is from the original Bootstrap 3 example I found, not Bootstrap 4)
HTML:
.somesection {margin-top:50px!important;}
body {
font-size:17px;
font-family:Helvetica Neue;
}
img {max-width:100%;}
.overlay-text {
font-size:3.5vw;
float:right;
width:65%; /*important*/
bottom:21vw; /*important*/
padding: 25px;
background:#f7f7f7;
}
<div class="container somesection">
<div class="row col-xs-6">
<img src="https://images.unsplash.com/photo-1459664018906-085c36f472af?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1087&h=725&q=80">
</div>
<div class="col-xs-3 col-sm-offset-4 overlay-text">
This is some text that should partially overlay.
</div>
</div>
However, that example uses Bootstrap 3 and breaks in Bootstrap 4 (the text displays horizontally below the image) and also does not stack the divs responsively.
I've tried screwing around with absolute and relative positioning, etc. it became a lot of code to execute cleanly and make responsive and I was hoping someone out there may have some insight into implementing in pure Bootstrap4...
If anyone out there can share any expertise here, I'd greatly appreciate it!
You could add a transform to your overlay column (you may need to cancel this with a media query for your smaller screens).
Please note in the html below, I have fixed your code to work with boostrap 4 - columns have to be inside a row (they cannot be on a row) and I don't think there is a -xs class any more
.overlay-text {
/* these two are needed - the align self makes the column not stretch the whole height of the image column and the translate moves the column over the image */
align-self: flex-start;
transform: translateX(-20%);
/* the following are for example only */
background-color: #ffffff;
padding:20px;
}
<div class="container somesection">
<div class="row">
<div class="col col-sm-6">
<img src="https://images.unsplash.com/photo-1459664018906-085c36f472af?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1087&h=725&q=80" class="w-100">
</div>
<div class="col col-sm-3 col-sm-offset-4 overlay-text">
This is some text that should partially overlay.
</div>
</div>
</div>
Example bootply
Just add position:relative; to the .overlay-text
You can also adjust the value of bottom
.somesection {margin-top:50px!important;}
body {
font-size:17px;
font-family:Helvetica Neue;
}
img {max-width:100%;}
.overlay-text {
font-size:3.5vw;
float:right;
width:65%; /*important*/
bottom:21vw; /*important*/
padding: 25px;
background:#f7f7f7;
position:relative;
}
<div class="container somesection">
<div class="row col-xs-6">
<img src="https://images.unsplash.com/photo-1459664018906-085c36f472af?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1087&h=725&q=80">
</div>
<div class="col-xs-3 col-sm-offset-4 overlay-text">
This is some text that should partially overlay.
</div>
</div>
I'm building a custom tooltip that uses position: fixed and a dynamic top and left to follow your mouse cursor around. The tooltip has a relatively complex layout built with flexbox. I'm having an issue with IE11 (which otherwise supports flexbox just fine using autoprefixer) where the width of the tooltip is getting collapsed down as if it had no content.
I made a Codepen stripping out all my implementation details except for the most basic Bootstrap layout and CSS, and the issue is still present. You can see it in action here https://codepen.io/ryangiglio/pen/xajLJr. Here is the code:
HTML
<!-- Regular content -->
<div class="container-fluid">
<div class="row">
<div class="col-4 text-center">
Column
</div>
<div class="col-4 text-center">
Column
</div>
<div class="col-4 text-center">
Column
</div>
</div>
</div>
<!-- Tooltip content -->
<div class="custom-tooltip">
<div class="container-fluid">
<div class="row">
<div class="col-12 text-center">
Tooltip Title
</div>
</div>
<div class="row">
<div class="col-4 text-center">
Column
</div>
<div class="col-4 text-center">
Column
</div>
<div class="col-4 text-center">
Column
</div>
</div>
</div>
</div>
CSS
.custom-tooltip {
position: fixed;
top: 50px;
left: 50px;
background: white;
box-shadow: 0 0 5px 1px black;
}
This is how it looks in Chrome
And how it looks in IE11
Unfortunately, I didn't care enough about the underlying issue here to spend too much more time solving it, so I ended up hard-coding a width on the .custom-tooltip class which solved the problem enough for me to ship it.
The link you provided was not valid cause I'm not a pro member.
On another note, I'm not sure, but it could be that when you set the box shadow property it changed the display, but I'm not sure and wanted to test that theory out but couldn't.
--- Edited
Try the below code you have to also make sure you correctly set the flex-direction property.
div.custom-tooltip{
display: flex;
flex-direction:column;
}
div.row{
display: flex;
flex-direction:row;
}
--- EDITED ANSWER ---
/*
I set the tooltip box containers
width to be a percentage, I don't
know if this a documented issue
with ie11 or not, where ie 11
doesn't realize that flex is being
used on a fixed element and goes with
default values for width.
*/
div[data-tooltip-boxwidth="300"] {
width: 20%;
}
I am building an app that uses Bootstrap. I want this app to have a footer. The footer needs to "stick" to the bottom. In other words, if the content is larger than the height of the screen, the footer should still be visible, the content goes under it. If the content takes less than the height of the screen, I still need the footer to stick tothe bottom. I tried using the sticky footer. However, that doesn't work. Currently, I am trying the following:
Here's My Plunker
My HTML looks like this:
<div class="footer">
<div class="container text-center">
<button class="btn btn-warning"><span class="glyphicon glyphicon-filter"></span></button>
<button class="btn btn-warning"><span class="glyphicon glyphicon-th"></span></button>
</div>
</div>
How do I build a footer that permanently sticks to the bottom? I'm basically trying to build an "action bar" that is visible only when the site runs on a phone.
Thank you for your help.
use the following code
.footer {
background-color: #f5f5f5;
bottom: 0;
height: 60px;
position: fixed;
width: 100%;
}
you should change the footer position :
.footer {
background-color: #f5f5f5;
bottom: 0;
height: 60px;
position: fixed; /*change it*/
width: 100%;
}
Bootstrap comes with its nav elements ready to roll as a footer.
Simply create your element and add these classed navbar navbar-default navbar-fixed-bottom.
<footer>
<div class="navbar navbar-default navbar-fixed-bottom" id="footer">
<div class="container">
<p>this is your footer that sticks to the bottom</p>
</div>
</div>
</footer>
You can then expand on this by splitting the containing div into blocks with something like
<div class="row">
<div class="row">
<div class="col-xs-8 col-sm-6">
Level 2: .col-xs-8 .col-sm-6
</div>
<div class="col-xs-4 col-sm-6">
Level 2: .col-xs-4 .col-sm-6
</div>
</div>
</div>
the above would go inside the container div
as shown here http://jsfiddle.net/showcaseimagery/5y14pqgv/
I have some divs that should take the entire height of a page. I managed to get this working as i needed. (Some fixed rows and some flexible rows) like in a html table.
I took the solution from one of my other questions here:
Layout divs in css like table cells in HTML Tables
Today i had to add a div inside the flexible row which should take 100% of the height of the flexible row. Which works great in all major browsers. Muahaha that was a good joke wasn't it? Of course this doesn't work as expected in IE see my js fiddle:
<div class="tableContainer">
<div class="row rowA">
<div class="cell">Test</div>
</div>
<div class="row rowB">
<div class="cell">Test</div>
</div>
<div class="row rowC">
<div class="cell">Test</div>
</div>
<div class="row rowD">
<div class="cell testcell">
<div class="testcontent">Test</div>
</div>
</div>
<div class="row rowE">
<div class="cell">Test</div>
</div>
</div>
http://jsfiddle.net/7ewEJ/3/
the ie seems to take the "100%" from the page and not from the enclosing flexible table row. So the blue div should take the whole space of the purble table row.
Am i doing anything wrong?
Could this be a bug in ie's height calculation?
http://jsfiddle.net/7ewEJ/5/
div.testcell{
height: 100%;
width: 100%;
min-width: 1px;
min-height: 1px;
/*background: #fff;*/
align: center;
display: block;
}