Pure CSS dynamic 2-column picture/text - html

My layout is like this:
<section class="container">
<div class="picture-div">
<figure><img src="blah"></figure>
<figure><img src="blah"></figure>
...
</div>
<div class="text-div">
<p>Text which could be very very very very very very very very very very very very very very very very very very long</p>
<p>Text which could be very very very very very very very very very very very very very very very very very very long</p>
...
</div>
</section>
Both the picture-div and the text-div have dynamic width according to their content. The picture-div has a min width of 500px and the text-div has a min width of 300px.
I want a dynamic effect matching the following rules:
The element following the container should have float both cleared and the content fully below the container element.
If the viewport width is not enough, the horizontal scroll bar should always be placed on the HTML element instead of the container, picture-div, or the text-div element.
If the container width exceeds (picture-div width + 300px), the text-div floats at the right of the picture-div and takes whole left space of the container. (eg. if container width is 2000px and picture-div width is 800px, then picture-div takes 800px and text-div takes 1200px.)
If the container width doesn't exceed (width of picture-div + 300px), the text-div doesn't float and both the picture-div and the text-div take full container space. (eg. if container width 1000px and picture-div width 800px, then both picture-div and text-div take 1000px)
Is there a pure CSS solution for this?

I'm kinda bad with syntax far as what you might be asking for, but thought I'd give it a shot to see if you might be able to follow this after in order to fix your issue.
It sounds like you want a responsive layout that will respond to maximum screen width and do specific things at each max or min width that the window shows. The floats would just be different classes that you could add in, I normally just use class="fl" and include that in my css. Here's a small example of what I have that pretty much does what I think you're asking.
<div id="panel-1-index">
<div class="row">
<div class="large-4 columns">
<img src="your-image.gif"/>
</div>
<div class="large-8 columns">
<p>Your Text Content</p>
</div>
</div>
</div>
Then your css would associate each of the class="large-* columns" as a certain width percentage. For the example above it would be:
.large-4 { position:relative;width:33.333% }
.large-8 { position:relative;width:66.667% }
The row and columns css properties will essentially just provide you with specific padding parameters and 100% width. After that, it would just involve you adding media queries that would give the classes different behaviors depending on screen widths.
The example I gave you is from use with my own site utilizing Zurb Foundation css framework. The first part of your question I couldn't really answer cause I have no idea - but the rest can be accomplished by looking at Foundation framework styles that shoot for responsive design. In my very limited experience, I would also suggest not using pixels for your measurements and instead go with percentages or em measures for better responsive design.
Let me know if I was far off, or just trying to tell you something you already know :)

Related

Only one div as xs resolution on lg

I would like to get unusual behavior bootstrap and media-query.
The content of one div (a) should be dependent on his width and not the width of the browser window. In the case of the picture (a) has a width of 600px and should be displayed as XS, and the container should act as LG.
You are thinking of Bootstrap incorrectly.
The point of bootstrap is to allow you to easily modify the behavior of elements depending on the width of the screen. If you're using only the grid system for example, all you're modifying is the width of the elements themselves based on the width of the screen.
If you want your a element to behave as sm at all times, regardless of the width of the screen (or at least until it reaches xs, for example) then you can use something like:
<div class=" div-a -col-sm-6"></div>
This will tell bootstrap to display the div A with 6 columns as long as the screen width is bigger than sm.
I'm not sure what you mean by "the container to act as LG" but I assume you mean it should be modified only for LG screens. Then:
<div class="container-div col-LG-12 col-*-newSize">
<div class=" div-a -col-sm-6">
*content*
</div>
<div class="container-b-c col-*-6"
<div class"div-b col-*-12"
-content-
</div>
<div class"div-c col-*-12"
-content-
</div>
</div> //End of container-b-c
</div> //end of container-div
where * is the size you need.

A div with min-width in a column, Bootstrap 3.2

I have two Bootstrap columns:
<div class="row">
<div class="col-md-6"><div class="my"></div></div>
<div class="col-md-6">some text</div>
</div>
They are both half a grid due to col-md-6. Now, I need set up the minimal width of div.my. If I apply min-width, I have a side-effect: when minimizing, at one point the div.my overlaps the parent column (before both columns are 100% width).
I have no intention to set up minimal width of the column itself, because div.my could have margins.
I know, I can use media-queries, but is there a better solution?
Regards,
Firstly use media queries, what reason is there not to?
They will give you complete control of how things look at any given size.
To prevent the overlapping div causing problems you could use.
.col-md-6 {
overflow: hidden;
}
It would be better to use a different class though, .col-md-6.no-overflow for example.
It's difficult to give a conclusive answer without knowing the content and purpose of the .my div.
<div class="row">
<div class="col-sm-6" style="min-width:300px !important;"><div class="my"></div>
</div>
<div class="col-sm-6">
</div>
</div>
Try this
min-width property is used to set the minimal width that that div will have in any case so it will not go below this width. You have to use max-width for that so:
div.my
{
max-width: 80%
}
For responsiveness its always good to use %
you could have use calc() feature of css for width, min-width etc.

Bootstrap container or Well keep the well one size and enlarge text

I am trying to fill a container, or a well, I believe the container will work better though. I need the container to stay the size it is in this Jsfiddle, but I need the Text to enlarge and stretch closer to the borders.
<div class="container-fluid color-back">
<div style='font-size:2500%; color:orange; text-align: center'>
Text
</div>
</div>
This is little harder to do but not impossible. You need to calculate the container width and set the fontsize accordingly. It is tricky since the font size will vary based on the number of characters in the text. A javascript based solution is probably easier to do. Did you look at something like http://fittextjs.com/?
For pure css based solution look in to vw and vh. They are not exactly fit for a container but based on viewport size.

Bootstrap responsive images ideal width

The question I have is pretty simple.
I have a div with responsive images. on sm the divs are full width like:
<div class="row">
<div class="col-md-4">
<img src="/img/picture1.jpg" class="img-responsive">
</div>
<div class="col-md-4">
<img src="/img/picture2.jpg" class="img-responsive">
</div>
<div class="col-md-4">
<img src="/img/picture3.jpg" class="img-responsive">
</div>
</div>
Bootply
What width in px should I use for the pictures, i want the highest quality for the picture thats possible.
Im not overruling any bootstrap css so its for default bootstrap 3.
Also i know the larger the image resolution the better the quality, but a 4k image would be useless on a div sm in bootstrap and is a waste of resources.
Assuming that you use fixed containers and an untasted bootstrap CSS the container width for small devices is 750px (720px + grid-gutter-width).
That means the widest possible column/image can be 720px (container width - gutter). So if you want to guarantee the images are displayed in best quality they must be at least 720px wide and 1440px to cover retina screens.
There is not a maximum browser width so the short answer is "as big as you can" (but take into account that the bigger the image is, the longer it takes to load).
What I would to is to do it in a way similar to Bootstrap. Bootstrap sizes go from extra-small to large and it considers large containers (when not fluid) to be 1170px width, so it has to be at least a third of that, 390px (330px if we remove the gutter space).
Moreover, it is shown at full width at small screens which bootstrap consider to have 750px (720px if we remove the gutter space) so the minimum updates to 720px.
But, if you want your web to look great on retina devices or similar, you should use images twice as big, so the result would be 1440px (but you should use those big ones just in that kind of devices)
I would look for a compromising solution between size and weight.
The col-md-4 class forces bootstrap to split the three horizontal images into three columns when the browser width is 768 pixels or less. The gutter width is 15px so
the best image width is 738px.
This would work for screen widths up to 3*768 = 2304px.
Most screens will be covered under this (see below)
https://www.w3schools.com/browsers/browsers_display.asp
For larger widths you should test depending on your requirements...

CSS fluid design issue

I am planning a fluid-design based layout with 2 cols as follows;
Below is the HTML code:
<div id="container">
<div class="fl wd5percent"><img src="titleText.jpg" /></div>
<div class="fl wd95percent"></div>
</div>
Here the 1st col contains the image for title text and remaining width is used for other content.
Now my issue is as this is a fluid layout, I cannot use "px" width anywhere... I define img to use max-width:100%, but that kind of creates blank space (or gap) below the titleText image when the 2nd col height is more.
How do I define my CSS such that the page scales well as the browser is resized. By that, I mean whatever be the browser size, the titleText image would be displayed to occupy full height as the content height of 2nd col..
Again, I cannot use px width or height anywehere in my CSS. So I cannot say, width:200px;height:100px
Please see the below fiddle link:
http://jsfiddle.net/thilakar/xKrws/2/