Im trying to position some buttons below a slider and I can do so, but the entire site is responsive (botstrap) except for these buttons. So I'm trying to make them so.
I have been trying to work with percents to position them and create fluid heights and widths, but I have had no luck. All I can seem to do is position them on top of one another.
My html looks like this
<div class="col-md-12 sliderBar">
<img src="assets/img/aboutPage.png" alt="" />
</div><!--.col-md-12-->
<div class="col-md-12 sliderNav">
<div class="container">
<button> < </button>
<button>Sponges</button>
<button>DBM</button>
<button>Synthetics</button>
<button> > </button>
</div><!--.container-->
</div><!--.col-md-12-->
and my css looks like this
.sliderNav{
background-color: #1b1a29;
text-align: center;
position:relative;
padding-bottom:3%;
height:0;
overflow:hidden;
}
.sliderNav button{
position:absolute;
width:20%;
height:100%;
}
Any help would be great! I have a fiddle set up here.
this what you want? fiddle
the changes i made are position to relative for button, set button width 15%.. let me know if works :)
here is the code i modified:
.container button{
position:relative;
width:15%;
height:100%;
}
Try this (no additional css needed):
<div class="container">
<div class="col-md-12 sliderBar">
<img src="http://upload.wikimedia.org/wikipedia/commons/4/41/Blank_Earth_Banner.jpg" alt="" class="img-responsive" />
</div><!--.col-md-12-->
<div class="col-md-12">
<div class="btn-group btn-group-justified">
<a class="btn btn-default"> < </a>
<a class="btn btn-default">Sponges</a>
<a class="btn btn-default">DBM</a>
<a class="btn btn-default">SYNTECHICS</a>
<a class="btn btn-default"> > </a>
</div>
</div>
</div>
Related
I have a row with header text and a button on the right.
<div class="page-header">
<div class="pull-right">
<button type="button" class="btn btn-success pull-right">Set All Values</button>
</div>
<h4>Points Earned for Each Chapter</h4>
</div>
The code above is what I have currently but I have tried many variations. In all of them, the button is not vertically aligned with the text. (The image below includes the overlay when I hover over the element in the Elements pane of Chrome, in order to show vertical alignment.)
Searching existing questions on stackoverflow, I've found this question posted a number of times; however, I found no knowledgeable answers.
Has anyone figured this out?
This happens because the line-height of the heading and the height of the button differ.
With a line-height: 1.9; for the heading it should work:
.page-header h4 {
line-height: 1.9;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="page-header">
<div class="pull-right">
<button type="button" class="btn btn-success pull-right">Set All Values</button>
</div>
<h4>Points Earned for Each Chapter</h4>
</div>
You can try using the grid to be mobile friendly and make everything inside vertically aligned.
<div class="page-header vertical-center">
<div class="row">
<div class="col-md-8">
<h1>Text on the left</h1>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-success pull-right">Set All Values</button>
</div>
</div>
</div>
Add this CSS
.row > div {
border: 1px solid black;
}
.vertical-center .row {
display: flex;
align-items: center;
}
/*maybe create an id instead of h1*/
h1 {
margin: 0;
}
What CSS do I need to use so that one img "under construction" is overlayed in the top left corner of the 1st image. The section of script this pertains to is the second column in the row. I've tried various solutions using position in css but have come up with nothing that is consistent with page resizing. I need a responsive solution.
<div class="col-lg-6">
<h2 class="text-center">Current Conditions</h2>
<img src="#Url.Content("~/Content/Img/weather4.png")" id="current-weather-logo" class="img-responsive center-block" />
<p class="text-center">View the current weather conditions in relation to Crestwood Assets</p>
<p class="text-center">
Launch <span class="glyphicon glyphicon-chevron-right"></span>
Documentation <span class="glyphicon glyphicon-chevron-right"></span>
</p>
</div>
<div class="col-lg-6">
<h2 class="text-center">Historical Weather</h2>
<img src="#Url.Content("~/Content/Img/weather4.png")" id="current-weather-logo" class="img-responsive center-block" />
<img src="#Url.Content("~/Content/Img/under-construction.png")" id="under-construction" class="img-responsive center-block img-overlay" />
<p class ="text-center">Leverage historical weather data for analysis with asset data.</p>
<p class ="text-center">
Launch <span class="glyphicon glyphicon-chevron-right"></span>
Documentation <span class="glyphicon glyphicon-chevron-right"></span>
</p>
</div>
</div>
EDIT
I modified to include the images in a div and provided some additional CSS.
<div id="img-container">
<img src="#Url.Content("~/Content/Img/weather4.png")" id="current-weather-logo" class="img-responsive center-block" />
<img src="#Url.Content("~/Content/Img/under-construction.png")" id="under-construction" class="img-responsive center-block img-overlay" />
</div>
.img-overlay{
position:absolute;
top:0;
left:0;
z-index:3;
}
#img-container{
position:relative;
}
EDIT 2
I attempted to fit it using the top and left attributes:
.img-overlay{
position:absolute;
top:0;
left:14.5%;
z-index:3;
}
This worked great at my initial width but when sized down to a smaller window it is pushed in. I would like to be consistent.
Here's how to put a picture above another picture: http://codepen.io/ruchiccio/pen/ZWZEEy
More than that I can't help because you haven't supplied normal paths to images so we can't see what should go onto what. Maybe provide a screenshot of what you'd like.
<div id="container">
<img id="pic1" src="http://placehold.it/350x150">
<img id="pic2" src="http://placehold.it/150x50">
</div>
#container {
position: relative;
}
#pic2 {
position: absolute;
top: 0;
left: 0;
z-index: 3;
}
I am trying to create a simple menu using the following html setup:
<div class="container">
<div class="container-cell">
<a href="play.html">
<div class="menu-option no-margintop">
<div class="play-icon">
<span class="helper"></span><img src="./img/icon_1.png"/>
</div>
<div class="menu-text"><span>Play</span></div>
</div>
</a>
<a href="index.html">
<div class="menu-option">
<div class="play-icon">
<span class="helper"></span><img src="./img/icon_3.png"/>
</div>
<div class="menu-text"><span>Highscore</span></div>
</div>
</a>
<a href="index.html">
<div class="menu-option">
<div class="play-icon">
<span class="helper"></span><img src="./img/icon_2.png"/>
</div>
<div class="menu-text"><span>FAQ</span></div>
</div>
</a>
</div>
</div>
In the process of creating this, I made a switch from hard pixels to percentages. Whereas the pixel version of setting hights works, it does not seem to work in percentages. The hight for one particular class, menu-option, does not seem to get picked up by the browser.
I have been searching for a while, and the only solutions I came across, was setting a height to both the body and html (100%). I have also set a height to any of the container-elements.
See css below:
html, body{
height:100%;
}
.container {
display:table;
width:100%;
height:70%;
}
.container-cell {
display:table-cell;
vertical-align: middle;
height:100%;
}
.menu-option{
width:90%;
margin-left:5%;
border-radius:10px;
background-color:rgba(17,23,28,0.2);
height:6.94%;
margin-top:5%;
font-size:150%;
}
Why is the browser not picking up on the height in percentage and how can make it use the height in percentage?
Add display: inline-block; to your menu-option class for the height property to work. Something like this:
.menu-option{
display: inline-block;
width:90%;
margin-left:5%;
border-radius:10px;
background-color:rgba(17,23,28,0.2);
height:6.94%;
margin-top:5%;
font-size:150%;
}
Here's a jsfiddle of the above: https://jsfiddle.net/AndrewL32/e0d8my79/17/
I know its been asked a million times but none of the search results seemed to work for me.
I am wondering how i can make my image to the same size as the display. I know i have to give the parent of the image a height and width so that i can use Height:100% but how can i give its parent a height and width that is different for every device?
I used position:absolute but that just made all the other content sit on top of my picture :(
am using bootstrap as well (encase you need that info)
any help would be boss! thanks!
A lil bit of my markup
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >
**this img below to be the size of users display**
<div style="background-color:#efefef; background-image: url(/App_Themes/Biz/Images/home-main.jpg); position: static; height:100%; width:100%; background-position:center bottom; background-repeat:no-repeat; background-size:cover;">
<div class="container" style="height:1200px;">
<div class="jumbotron" style="color:#fff; background-color:transparent; text-align:center;">
<h2 style="font-weight:bold!important;">FREE rents</h2>
<p>The easy way to rent out stuff</p>
<p><a class="btn btn-default" role="button" href="#moreInfoPanel" id="findOutMore">FIND OUT MORE</a> <a class="btn btn-primary" href="/Account/Add-Property" role="button">rent it now</a></p>
</div>
</div>
</div>
<div style="background-color:#eff5f7; border-top:solid 1px #e6e9ea; border-bottom:solid 1px #e6e9ea;">
<div class="container">
<img src="App_Themes/biz/Images/sign.png" alt=" Portals" style="padding:5% 0%; width:100%;" />
</div>
</div>
<div>
<div class="container" id="moreInfoPanel">
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-4" style="margin:60px 0px 40px 0px">
<div style="text-align:center; padding:10px 30px; border:solid 1px #e7ecef; border-bottom:solid 5px #e7ecef;">
<img src="App_Themes/biz/Images/free.png" style="margin-top:-55px;" alt="Lets Rent - FREE" />
<h4>Free</h4>
<p>
some stuff
</p>
<a href="Pricing" title="Read More - Pricing" class="btn btn-primary" style="margin-bottom:-40px;" >read more</a>
</div>
</div>
<div class="col-xs-12 col-sm-4 col-md-4" style="margin:60px 0px 40px 0px">
<div style="text-align:center; padding:10px 30px; border:solid 1px #e7ecef; border-bottom:solid 5px #e7ecef;">
<img src="App_Themes/biz/Images/quick.png" id="quickImage" runat="server" style="margin-top:-55px;" alt="QUICK" />
<h4>Quick</h4>
<p>
more crap
</p>
<a href="Benefits" title="Read More - Benefits" class="btn btn-primary" style="margin-bottom:-40px;" >read more</a>
</div>
</div>
<div class="col-xs-12 col-sm-4 col-md-4" style="margin:60px 0px 40px 0px">
<div style="text-align:center; padding:10px 30px; border:solid 1px #e7ecef; border-bottom:solid 5px #e7ecef;">
<img src="App_Themes/biz/Images/easy.png" style="margin-top:-55px;" alt="EASY" />
<h4>Easy</h4>
<p>
boom stuff here!
</p>
<a href="Benefits" title="Read More - Benefits" class="btn btn-primary" style="margin-bottom:-40px;" >read more</a>
</div>
</div>
</div>
</div>
One easy and fast way to do this is use vh-units. Check that you have proper browser support in http://caniuse.com/#feat=viewport-units
css:
.full-img{
height:100vh; /* This means 100 percent of viewport height */
background:red;
}
html:
Above the full height block
<div class="full-img">
<p>This takes 100% of viewport height = 100vh</p>
<p>check http://caniuse.com/#feat=viewport-units for browser support</p>
</div>
Below the full height block
I have a web page which is designed using twitter bootstrap along with it's responsive css inclusion to make everything responsive on different window sizes.But the image in the following codes not re-sizing itself when browser resized, so is not showing responsiveness
<div class="container-fluid">
<div class="row-fluid">
<div class="span"> <div class="media">
<img class="mod-picture" src="images/picture.jpg" alt="post picture" /> <div class="media-container"><a class="link-name" href="#" target="_blank">media name</a></div>
</div></div></div></div>
In css file styles are -
.media-link
{
float:left;
border:1px solid #ccc;
display:inline-block;
color:#3B5998;
cursor:pointer;
margin-right:5px;
}
.mod-picture{
margin-right:10px;
border:0;
display:block;
margin:3px;
}
but if i remove float:left; and display:inline-block; styles from media-link class then image is resizing on browser window size changes.But i can't remove these two properties because next content with class "media-container" need to be appear on right.I tried in many ways like adding float:left in the div before link but failed.Please suggest me.
If you are using bootstrap 3, then you may need to add the class 'img-responsive' to your 'img' tag.
You can take styles from Bootstrap 3 and apply for your code:
<a href="http://facebook.com" target="_blank" class="media-link">
<img class="mod-picture" src="images/picture.jpg" alt="post picture" />
</a>
.media-link{
//nothing styles
}
.mod-picture{
// max width of image
max-width: 50%;
float: left;
display: block;
border:1px solid #ccc;
}
If you are using bootstrap 3 which you should. Then just add class img-responsive to img tag. and That's all to make it responsive.
Here is CDN link for bootstrap3 css. You don't even need to add bootstrap-responsive css.
//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"
In case bootstrap 2.3 existing problem use this-
<div class="container-fluid">
<div class="row-fluid">
<div class="span-12">
<div class="media">
<a href="http://facebook.com" target="_blank" class="media-link">
<img class="mod-picture" src="images/picture.jpg" alt="post picture" />
</a>
<div class="media-container">
<a class="link-name" href="#" target="_blank">media name</a>
</div>
</div>
<div style="clear:both"></div>
</div>
</div>
</div>
.mod-picture{
width:40%;
padding:5%;
max-width: 200px;
height:auto;
float:left;
}
.media-container{
display:inline-block;
}