i have a div that is a content for a video, and it is working fine, but the problem is, that everytime i try to see how it adapts on diferent devices the height of the video just decrease, i think it is the normal behaviour of bootstrap, but the thing is i need that div to increase when the devices are smaller, how can i do that?
here is my html for the video and text inside
<section class="content_section white_section bg2">
<div class="embed-responsive embed-responsive-16by9">
<div id="video_overlays"></div>
<div class="container vertical-center ">
<div id="over">
<div class="title-wrapper main_title centered upper">
<h2><span class="line"></span>Simple solutions for complex problems</h2>
</div>
<div class="description4 centered">
<p dir="ltr"><b id="docs-internal-guid-7b963bcb-e991-08ff-b846-612f8d57baee">The world is a complex place. </b><br><b>Our solutions are designed to allow organisations to quickly and simply use their information without adding layers and layers of heavy software.<br>
Usability and simple deployment are the key words.</b></p>
</div>
</div>
</div>
<div id="player" width="100%" height="100%" style="z-index:-1">
</div>
</div>
</section>
you can do it using media queries. Assuming that the div holding your video player has id #player. Note all the px and vh values used below are just for an example. you may set them as you want. In the below examples smaller devices have the video player with an increased height.
#media screen and (min-width: 1200px ) {
#player {
height:500px; //or height:50vh
}
}
the above code means that for screen sizes having a width above 1200px the height will be 500px ( you can set it to whatever you want)
#media screen and (max-width: 1199px) and (min-width: 600px) {
#player {
height:700px; //or height:70vh
}
}
the above code means that for screen sizes having a width between 600px and 1199px the height will be 700px. and the code below means for screen resolutions below 600px the height of the video player would be 800px.
#media screen and (max-width: 599px) {
#player {
height:800px; //or height:80vh
}
}
Read more about media queries here :
https://www.w3schools.com/css/css3_mediaqueries_ex.asp
Related
I'm using an iPhone CSS device from https://marvelapp.github.io/devices.css/
However, I can't find an intelligent way to make it resize to fit within mobile devices. The only way I've found is by changing the meta viewport's initial scale, but that changes how the entire Bootstrap website appears on mobile, not just the mobile device obviously.
Is there a way to perhaps change the scale for the specific div within which the CSS mockup resides, or another way to make the device resize for mobile view?
A transform: scale() seems to work.
The scale could be set using JS based on the viewport width to make it fit the screen.
.small {
transform: scale(0.5);
}
<link href="//marvelapp.github.io/devices.css/assets/devices.min.css" rel="stylesheet"/>
<div class="marvel-device iphone6 silver">
<div class="top-bar"></div>
<div class="sleep"></div>
<div class="volume"></div>
<div class="camera"></div>
<div class="sensor"></div>
<div class="speaker"></div>
<div class="screen">
<!-- Content goes here -->
</div>
<div class="home"></div>
<div class="bottom-bar"></div>
</div>
<div class="marvel-device iphone6 silver small">
<div class="top-bar"></div>
<div class="sleep"></div>
<div class="volume"></div>
<div class="camera"></div>
<div class="sensor"></div>
<div class="speaker"></div>
<div class="screen">
<!-- Content goes here -->
</div>
<div class="home"></div>
<div class="bottom-bar"></div>
</div>
You must to do it manually using "medias" to determine how it should look in certain devices. Media Queries are useful to make breakpoints on viewport sizes to adjust content and view it properly on different screen resolutions.
The following example shows how a media query changes some existing values de .marvel-device.iphone6 and .marvel-device.iphone6 .sensor at a resolution of 320px wide.
#media only screen and (max-width : 320px) {
.marvel-device.iphone6{
width: 320px; /*Or the new width you want in pixels*/
height: 480px; /*Or the new height you want in pixels*/
}
.marvel-device.iphone6 .sensor{
left: 50px; /*Or the left position for the sensor*/
}
}
As I said before, I don't know an other better way to do it but manually, so you need to copy that code, and modify these values to fit the screen resolutions you want. Unless you could use transform for the whole .marvel-device
I have an image of a fixed aspect ratio, but of responsive format, as the first item in a two column flex row, as follows:
<div class="d-flex flex-column flex-md-row">
<!-- main photo -->
<img class="" src="http://lorempixel.com/300/160" srcset="http://lorempixel.com/400/225 400w,
http://lorempixel.com/475/267 475w,
http://lorempixel.com/540/304 540w,
http://lorempixel.com/600/338 600w,
http://lorempixel.com/800/450 800w,
http://lorempixel.com/950/534 950w,
http://lorempixel.com/1080/608 1080w,
http://lorempixel.com/1200/675 1200w" sizes="(min-width: 1200px) 475px, (min-width: 992px) 400px, (min-width: 768px) 300px, (min-width: 576px) 540px, 100vw">
<!-- details -->
<div class="p-3 d-flex flex-column justify-content-center w-100">
<div class="py-2 scroll-overflow">
A LONG, LONG, LONG TEXT GOES HERE!
</div>
</div>
How can I have the long, long text above scroll into the div as soon as the "convenient" height is reached, that being the height of the neighbouring image. I cannot set a fixed height to the div since, the image being responsive, its height changes when the user moves the window.
This seems like a pretty standard use case for media queries. Whenever you find that you need to change something "when a convenient height is reached" (to borrow your words), you can consider using a media query to change the dimensions upon reaching a set dimension. Example:
#media (max-width: 1200px) {
.py-2 {
height: /* something */;
width: /* something */;
}
}
Hopefully this will provide you with the level of control over the div dimensions that you need.
I would like to generate a fixed width col for big displays with bootstrap, but it should be reponsive if you use it on smaller ones.
<div class="container">
<div class="col-md-3"></div> <-- this should be fixed width 400px for big displays
<div class="col-md-9"></div> <-- content should be always responsive
</div>
Is this possible? Thanks
The best way to get a fixed-fluid layout in Bootstrap 3 is using #media query that works at the same breakpoint as the Bootstrap media queries. So, in your case use the 992px (md) breakpoint...
#media (min-width:992px) {
#sidebar {
min-width: 400px;
max-width: 400px;
}
#main {
width:calc(100% - 400px);
}
}
Bootstrap Fixed-Fluid Layout
You can do this
<div class="container">
<div class="col-md-3 fixed-size-1"></div> <-- this should be fixed width 400px for big displays
<div class="col-md-9 fixed-size-2"></div> <-- content should be always responsive
</div>
CSS
.fixed-size-1{
//specify height and width
}
.fixed-size-2{
//specify height and width
}
Use CSS media queries to add fixed width to them.
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
you can add responsiveness by using
<div class="col-md-9 col-sm-9 col-xs-9"></div> <-- content should be always responsive
this will take 9 column in large tab and mobile screen
I have 3 HTML div elements that I'd like to see sit side-by-side on a wide screen but, as the screen width collapses, I'd like to see them become vertical.
For example...
Wide screen:
-----------
abc def ghi
-----------
Narrow screen:
abc
def
ghi
Currently, having three HTML divs that look as follows (in another div block) only lays them out vertically...
<div id="Master_Div">
<div id="Div_1">
<p>abc</p>
</div>
<div id="Div_2">
<p>def</p>
</div>
<div id="Div_3">
<p>ghi</p>
</div>
</div>
Maybe, the answer is tied to media queries and/or responsive design but I'm not sure.
Thanks for any help you can offer.
I would do something like this unless you actually need to apply an ID, classes are easier for multiple divs with one assignment in css, plus they take up less space.
html---
<div class="wrapper">
<div class="third">Something here</div>
<div class="third">Something here</div>
<div class="third">Something here</div>
</div>
css---
.third {
width: 33.333333%
float:left;
}
#media screen and (max-width: 767px) {
.third {
width: 100%;
float:none;
}
}
Yes, there are media queries that allow you to control layout for mobile screens, ex:
/* Portrait and Landscape */
#media only screen
and (min-device-width: 768px)
and (max-device-width: 1024px)
and (-webkit-min-device-pixel-ratio: 1) {
/* stack vertically */
}
A simple media query can do this.
/* Apply inner styles if the viewport's width is at least 500px */
#media (min-width: 500px) {
.responsive {
width:33.3333%;
float:left;
}
}
<div id="Master_Div">
<div class="responsive" id="Div_1">
<p>abc</p>
</div>
<div class="responsive" id="Div_2">
<p>def</p>
</div>
<div class="responsive" id="Div_3">
<p>ghi</p>
</div>
</div>
Your problem is best resolved by natural design patterns without resorting to media queries. Think about it this way , if you lay out your columns side by side using css float:left; and you define some min-width value per column. then as soon as the screen width becomes smaller than the width value you defined X 3 , your columns will be laid out vertically
I'm finishing up work on this website and trying to finalize the positioning of the slider navigation; however, I'm struggling to get the position correct on approximately tablet width screens (550px-768px).
I think something is off with my media queries and sizing but I can't put my finger on why I can't lock the position down between that range!
Here's a link to the correct behavior. Any ideas?
Slider uses Cycle2, if it matters!
Sample HTML
<div id="slider" class="cycle-slideshow" data-cycle-pager="#adv-custom-pager" data-cycle-slides="> div" data-cycle-timeout="7000">
<div class="singleSlide">
<!-- content goes in here -->
</div>
<div id="sliderNav">
<div id="adv-custom-pager">
<span class=""></span>
<span class=""></span>
<span class=""></span>
</div>
</div>
And CSS
#media screen and (max-width: 768px) and (min-width: 550px) {
#sliderNav {
bottom:145px;
}
.slidercaption {
height:250px;
}
}
I can't see anything wrong with the slider at that point.
To be honest when I add a slider to a website, I usually turn it off for mobiles and have just 1 image visible (to break the text up). The viewpoint is so small, people won't wait to watch for the slider to change unlike desktops when they could be reading something else and notice it change.