JSFIDDLE is here.
I have spans inside div which will split into 3 vertically align row. It works normally in high resolution browser but when I resize browser it colaps. You can resize jsfiddle window and u'll see what am I saying.
How can I solve that?
<div class="postPrevContent cal">
<span>იანვარი</span>
<span>თებერვალი</span>
<span>მარტი</span>
<span>აპრილი</span>
<span>მაისი</span>
<span>ივნისი</span>
<span>ივლისი</span>
<span>აგვისტო</span>
<span>სექტემბერი</span>
<span>ოქტომბერი</span>
<span>ნოემბერი</span>
<span>დეკემბერი</span>
</div>
Add a
min-width:100px
in your .cal span css class
You could use media queries in your CSS, this will make it into 2 columns instead of 3 when the page is below a 500px wide:
#media (max-width: 500px){
.cal span {
width: 50%;
}
}
http://jsfiddle.net/hqu6t0en/1/
you can then so the same again for a wide of 250px and make width 100% to make one column when even smaller. Or apply a minimum width to .col to stop it getting below 250px but keep 2 columns
#media (max-width: 250px){
.cal span {
width: 100%;
}
}
Or
.cal {
margin: 10px 0;
min-width: 250px;
}
change span to div, style float left and width in percent (of corse in *.css and class is beather), set min-width of parent div. 150 if you think text is max 50px width.
<div style="min-width: 150px; max-width: 800px;">
<div style=" width: 33%;float: left;">AAAAAAAA</div>
<div style=" width: 33%;float: left;">BBBBBBBB</div>
<div style=" width: 33%;float: left;">CCCCCCCCC</div>
<div style=" width: 33%;float: left;">AAAAAAAAAA</div>
<div style=" width: 33%;float: left;">BBBBBBBBBBBBB</div>
<div style=" width: 33%;float: left;">CCCCCCCCCCCC</div>
</div>
PS. Set max-width for big display. Set centre text in div.
Related
Here is the fiddle: https://jsfiddle.net/apo5u0mt/
Here is the code:
HTML
<div class="modal" id="galleryModal">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
<div class="modal-content">
<div class="gallery">
<div class="gallery-item">
<img src="https://preview.ibb.co/kPE1D6/clouds.jpg">
</div>
<div class="gallery-item">
<img src="https://preview.ibb.co/mwsA6R/img7.jpg">
</div>
<div class="gallery-item">
<img src="https://preview.ibb.co/kZGsLm/img8.jpg">
</div>
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#galleryModal">
Modal
</button>
CSS
.gallery {
overflow-y: auto !important;
}
.gallery-item {
margin: 5px;
float: left;
}
.gallery-item img {
height: 150px;
width: 200px;
object-fit: cover;
}
.btn {
margin: 5px;
}
There is some extra space on the right side of the modal. I do not want that space. I want the modal to fit the contents, which are images. I have been staring at this for entirely too long, and would appreciate any help.
Bootstrap is doing this:
.modal-dialog {
max-width: 500px;
}
The .modal-dialog element is a block element, and thus wants to be 100% width by default, but Bootstrap's styling is keeping it to 500px wide.
You're explicitly setting your images to be 200px wide each, which (ignoring margins for the moment) only adds up to 400px.
Two possible fixes are:
1. Override Bootstrap's modal styling here to constrain the modal to a narrower width:
/*
The value below is empirically tested,
allows for your given margins & floating. I originally expected it to be
420px = (200px width + 5px left margin + 5px right margin) * 2
but 422px was necessary to avoid wrapping when tested in jsfiddle
*/
.modal-dialog {
max-width: 422px;
}
https://jsfiddle.net/nftj9s7y/1/
If images being exactly 200px wide is what matters, then that's your solution. However, that seems like a brittle solution to me - it'll break if you decide to change image widths, and might not work at smaller screen sizes.
The more flexible solution would be:
2. Use flexbox to have images expand to fill the modal
.gallery {
display: flex;
flex-wrap: wrap;
padding: 5px;
}
/* now that the parent element is display: flex, we don't need floats anymore */
.gallery-item {
padding: 5px;
width: 50%;
}
.gallery-item img {
height: 150px;
object-fit: cover;
width: 100%; /* allow image to fill width of containing element */
}
https://jsfiddle.net/vzs98n6b/2/
And as a final note, .gallery { overflow-y: auto } won't have any effect unless you specify a height or max-height on that element.
I have the following issue. Based on resulotion, basically for mobile view i want still to have 4 divs but i want them 40% of viewport, so i will have 2 and a half div visible and 1 and a half should be overflown with scroll available.
i tried something like this:
#bsp-content {
width: 100%;
display: table;
padding-bottom: 15px;
#media all and (max-width: $mobile_breakpoint){
overflow-x: auto;
}
.bsp-container:last-child {
#include set_solid_border(0,$acc_grey,right);
}
.bsp-container {
width: 25%;
display: table-cell;
text-align: center;
#include set_solid_border(1,$acc_grey,right);
> div {
padding-left: 15px;
padding-right: 15px;
}
#media all and (max-width: $mobile_breakpoint) {
width: 40%;
}
}
where content is actually viewport and container is div (there are 4 of them).
Can anybody give me a hint please?
Note: I dont want to use javascript to recalculate viewport, and also i dont want to have them fixed width.
Thanks in advance.
UPDATE - html part
<div id="bsp-content" ">
<div class="bsp-container">
<img src="img1"/>
<div>text1</div>
</div>
<div class="bsp-container">
<img src="img2"/>
<div>text2</div>
</div>
<div class="bsp-container">
<img src="img3"/>
<div>text3</div>
</div>
<div class="bsp-container">
<img src="img4"/>
<div>text4</div>
</div>
</div>
You should use width: 40vw; instead of width: 40%;.
Hi,
See the screenshot, I'd like to know how I can fit my simple countdcown to always take 100% of the screen? I've made it to fit my phone, but Id like it to be 100% on the desktop aswell.
What I've tried:
html{
width:100%;
height:100%;
}
body{
width:100%;
height:100%;
}
But, this will only make the body 100%..
Where do I start? Does anybody have a tutorial or anything?
A simple example of using vw or vh (viewport), try it and you will see the difference.
Also with to center your element. you could use:
display: flex;
align-items: center;
justify-content: center;
Vertical Centering
REF: https://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/
Viewport
REF: https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag
body {
margin: 0;
}
.test1 {
background: red;
width: 100%;
height: 300px;
display: flex;
align-items: center;
justify-content: center;
}
.test2 {
background: green;
width: 100vw;
height: 300px;
display: flex;
align-items: center;
justify-content: center;
}
.innerwraper {
height: 100px;
width: 200px;
background: aqua;
}
<div class="test1">
<div class="innerwraper">This is 100% width</div>
</div>
<div class="test2">
<div class="innerwraper">This is 100vw</div>
</div>
Automatically the height and the width of the body is 100% and it can not be changed to an other value so your code is unuseful.
To make the content take bigger height and width you should modify the css height and weight properties of the content (buttons, text inputs, divs, etc).
You will have to define all sizes, lengths and widths in 'vw' and 'vh'. It stands for viewport width and viewport height. This will tell the browser to render every objects size relative to the width of the screen (or height, depending on what you choose).
In your example every object should be about 20vh heigh, with a margin of 5vh. Four objects make then a perfect 100vh (100% viewport height).
You could start with this css:
input, div {height: 20vh; margin: 5vh 1vh;}
You can wrap the entire combination of buttons and views in a div, for example:
<div id = "wrapper"> </div>
Then inside of the div modify each element's height and width based on percentages. For example, you have 4 elements vertically, and three buttons on the bottom. So your three buttons on the bottom could be further wrapped in another div making them act as one element. Then you can split the 4 elements to height: 25%; and make width inherited.
So it would look something like this:
<body>
<div id="wrapper">
<div class="element"> insert element here such as input </div>
<div class="element"> element here such as input button </div>
<div class="element"> element here such as counter </div>
<div class="element">
<div> </div>
<div> </div>
<div> </div>
</div>
</div>
CSS:
.element{
height:25%;
width:inherit;
}
#wrapper{
height:100%;
width: 100%;
}
Above all the properties inside the block of codes if there is no * {
box-sizing: border-box;
}
The Content will not fit in...
I'm wanting to make my images smaller as the window size gets smaller.
However, I have to define the size of these two images by width, yet because 'max-width' overrides 'width' then it makes the images really small? I need to use 'max-width' to resize my images. However, I have two images on the left hand side that I have used both width and max-width and its width is defined and it resizes? What am I doing wrong with the other two?
img {
width: 100%;
height: auto;
width: auto\9;
}
/* css for the two larger images on the left-hand side*/
#imageleft {
display: inline-block;
height: 30px;
}
/* css for the two smaller images on the right-hand side*/
#imageright {
display: inline-block;
width: 50px;
height: 100px;
}
<!-- large images to left -->
<div id="imageleft">
<a href="index.html">
<img src="images/photo-1464375117522-1311d6a5b81f.jpeg" alt="Guitar image" style="max-width:100%; width:600px;height:400px">
</a>
<a href="index.html">
<img src="images/photo-1470020618177-f49a96241ae7.jpeg" alt="Fire breather" style="max-width:100%; width: 300px;height: 400px">
</a>
</div>
<!-- small images to the right -->
<div id="imageright">
<a href="index.html">
<img src="images/photo-1472653431158-6364773b2a56.jpeg" alt="festival" style=" max-width: 100%; height: 200px">
</a>
<a href="index.html">
<img src="images/photo-1473396413399-6717ef7c4093.jpeg" alt="stage view" style="width:291px; max-width: 100%;height: 196px">
</a>
</div>
#helpme123 I really didn't get what kind of layout you desire to achieve. Could you change your post and provide an example of it, please?
When you use width and max-width together, it's usually because you are giving the element a width relative to its parent (or the viewport or the current font-size or the base font-size), but you also want to explicitly state an absolute width, beyond which the element should not widen.
Working Example:
div {
width: 90%;
padding: 12px;
}
.parent {
max-width: 1000px;
background-color: rgb(255,0,0);
}
.child {
max-width: 600px;
background-color: rgb(255,255,0);
}
.grandchild {
max-width: 400px;
height: 100px;
background-color: rgb(0,0,255);
}
<div class="parent">
<div class="child">
<div class="grandchild">
</div>
</div>
</div>
If you run the example in a full window and shrink the window size and then gradually grow it, you'll see that the divs each widen relative to their parent... until they reach their max-width, after which they stop widening.
The question sounds complex but here is HTML that illustrates it:
<div id="contained" style="overflow: hidden">
<div id="float-right" style="float: right; width: 100px">floated-right</div>
<div id="float-left" style="float: left; width: 200px">floated-left</div>
<div style="clear: both"></div>
</div>
If I resize #contained to less than 300px then #float-left jumps below it and is no longer visible.
Question is: How do I prevent #float-left from disappearing if I resize #contained to less than 300px? How do I make #float-right and #float-left "stick together" if #contained is less than 300px?
It is not possible to prevent #float-left from disappearing when the container #contained is resized to less than 300px - and has overflow:hidden and a fixed height (presumably) - because #float-left and #float-right have fixed widths of 100px and 200px. If you would like them to remain side by side you would need to give them percentage widths. You could also have them stack one on top of the other if you give the #container height: auto.
<div id="contained" style="overflow: hidden">
<div id="float-right" style="float: right; width: 33.3%">floated-right</div>
<div id="float-left" style="float: left; width: 66.6%">floated-left</div>
<div style="clear: both"></div>
</div>
You can use a media query to change the style when the page is below a certain width. Example:
body { margin: 0; padding: 0; }
#contained { overflow: hidden; background: #f8f8f8; }
#float-right { float: right; width: 200px; background: #ffc; }
#float-left { float: left; width: 300px; background: #ccf; }
#media (max-width: 500px) {
#float-right { width: 33.33%; }
#float-left { width: 66.66%; }
}
<div id="contained">
<div id="float-right">floated-right</div>
<div id="float-left">floated-left</div>
</div>
Note: You don't need a clearing element inside the container, as the overflow style will make it contain its children.