Somehow it seems i run into issues on that image matrix example again and again i deal with in combination with Susy. :/ In preparation of finishing the project by applying media queries to it making things responsive i initially inspected the current state and resized the browser window. There happened the following:
https://dl.dropbox.com/u/8578/Resize.mov
Both shown image matrices consist of raster images. The black image matrix resizes and enlarges without a problem. But the second matrix has issues on enlarging again. Is that a plain CSS issue or more Susy related? And is there a way to fix it? :/
The basic Susy settings are:
$total-columns: 24;
$column-width: 3%;
$gutter-width: 1%;
$grid-padding: 0;
For images the following was applied:
img{
width:100%;
max-width: 100%;
height:auto !important;
}
The HTML part for the first matrix looks like that (i've entered only one li element - the other 27 differ only in title and linked images):
<ul class="customers sectionwrap">
<li><a><img title="Company" src="img/logo.png" alt="Logo" /></a></li>
</ul>
The Susy and layout relevant CSS parts for the first matrix (7x4) look that way:
.customers {
#include with-grid-settings($gutter: 0.1%){
li {
margin-right: -100%;
#include span-columns(2,14);
#include nth-omega(7n);
#for $g from 1 through 28
{
&:nth-child(#{$g}){#include push(0);}
}
}
}
}
The HTML part for the second matrix looks like that (i've entered only one li element - the other 8 differ only in title and linked images):
<ul class="moodlegrid sectionwrap">
<li><a class="ajax1" href="projekt1.html"><img title="Projekt1" src="img/1.jpg" alt="Projekt1" /><img title="Projekt1" src="img/2.jpg" alt="Projekt1" /><span class="spiceup">Zum Projekt</span></a></li>
</ul>
The Susy and layout relevant CSS parts for the second matrix (3x3) look that way - they are split because they are located in different partials:
.moodlegrid{
#include with-grid-settings($gutter: 0.8%){
li{
margin-right: -100%;
#include trailer(1 / 2);
#include span-columns(6,18);
#include nth-omega(3n);
#for $i from 1 through 9
{
&:nth-child(#{$i}) {#include push(0);}
}
}
}
}
.moodlegrid{
li{
a{
position: relative;
float:left;
display:block;
img:nth-child(1){
float:left;
display:block;
}
img:nth-child(2){
display: none;
}
span{
display:none;
}
}
a:hover{
img:nth-child(2){
display: block;
position: absolute;
z-index: 100;
top:0;
left:0;
}
span{
display: block;
position: absolute;
text-align:center;
top: 42%;
left: 34%;
z-index:101;
padding: 0.24em;
#include border-radius(5px, 5px);
#include box-shadow(black 2px 2px 10px);
}
}
}
}
I'd bet that your problem comes from floating the a tags that wrap the images. When you float something it creates a new layout context. If you don't set a width, the float collapses to the smallest possible size. Your img setting width: 100%; is figured as 100% of the collapsing a rather than 100% of the li. You can either remove the float or set width: 100%; on the a as well.
Related
I have an image of TV set and I want to place images of "shows" in it, centered horizontally on the screen (in front of the tv screen image). I'm using a to set the dimensions of the area in which to place the images, but I don't have to if it's not necessary. I've fiddled with position:absolute/relative of the and the images, but I can't get both images to be centered and stacked - either they partly overlap when centered or they align perfectly at the edge of the "". Here's the current iteration of the code. Any advice would be appreciated.
<div id="sourceDiv" align="center">
<img class="test" src="uvaCover.jpg" style="z-index:2; width:800px">
<img class="test" src = "tvScreen.jpg" style="z-index:1; width:900px">
</div>
.test {
position: absolute;
display: block;
margin:auto;
height:auto;
overflow: hidden;
}
#sourceDiv {
position:relative;
background-color: red;
top:170px;
left: 20px;
width:1000px;
height: 800px;
margin:auto;
}
I found the answer. For the ":
display: flex;
align-items: center;
justify-content: center;
I often float images either left or right around text on desktop but I want them centered for small mobile devices and the paragraph to drop below the image using Responsive design. I've got the paragraph dropping below the image using an online mobile viewing device but not when I try to view it via my computer. The image won't center online or on my computer.
Here is what I have found after many hours of research:
I have this set up for all images:
img{
border:0;
max-width:100%;
height:auto;
}
I have this set up for all paragraphs: it pushes the paragraph down below a floated image when the width of the paragraph is less than 10em (about 200 px).
p:before{
content: "";
width: 10em;
display: block;
overflow: hidden;
}
I have applied the following for images to media queries less than 320 and max of 480:
img{
max-width:100%;
display:block!important;
margin:0 auto !important;
float:none !important;
}
(i had to add !important to some of them or they wouldn't take but it's still not accepting margin: 0 auto; )
Can anyone see what I'm doing wrong?
Here you have a working update of what you need: http://jsfiddle.net/ancpjmet/3/
I changed min-devide-width to min-width and max-devide-width to max-width to be able to see the changes on my desktop browser in Google Chrome.
You have to set the div wrapping the img to float: none;, not the img:
#media only screen and (min-width:320px) and (max-width:480px) {
#image-wrapper{
float: none !important;
}
#image-wrapper img{
max-width: 80%;
display: block;
margin: 0 auto;
}
}
I also rebuild your .clearfix class to be more consistant and work in all browsers:
.clearfix:before,
.clearfix:after {
content: '\0020';
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0; }
.clearfix:after {
clear: both; }
.clearfix {
zoom: 1; }
Take a look at the changes in the jsfiddle given.
This question already has answers here:
Additional margin of 5px when inline-table or inline block is used [duplicate]
(4 answers)
Closed 8 years ago.
I have this html code:
<nav>
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
</ul>
</nav>
And this css:
nav {
display:block;
}
nav ul {
display:inline-block;
width:100%;
list-style-type: none;
margin:0;
padding:0;
}
nav ul li {
float: left;
width: 100px;
height:100%;
margin-right: calc((100% - 500px) / 4);
}
nav ul li:last-child { margin-right:0; }
nav a {
display:inline-block;
width:100%;
height:100%;
}
JSFIDDLE HERE
As seen on jsfiddle there is white space after ul but nav is higher. Setting ul to 100% doesn't help and it doesn't seem to be margin. What is it?
The space: http://i.imgur.com/NSKqsUV.png
Hi check here http://jsfiddle.net/j5LLR/1/ it works. The problem is because of using:
display: inline-block;
to your ul. So i ve added
vertical-align: top;
there too. Unfortunately inline-block causes many weird space issues.
Make the body have margin: 0.
That will fix the problem!
Here's the fiddle:
http://jsfiddle.net/j5LLR/
Change the vertical-align for ul for default is baseline making the calculation with line-height and other values create that gap:
The baseline of an 'inline-block' is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its 'overflow' property has a computed value other than 'visible', in which case the baseline is the bottom margin edge.
nav ul {
vertical-align:top;
}
The demo http://jsfiddle.net/n9uu4/2/
I'm trying to fill a window with an image. I'm using CSS to try to work this, but I was wondering if there's a way to maximize the width/height of the image until all the white space is filled, but not ruin the quality.
<div class='rel-img-cont'>
<img src='src.jpg' />
</div>
.rel-img-cont
{
width: 100px; height: 100px; overflow: hidden;
}
.rel-img-cont img
{
height: 100px; margin:0 0 0 0;
}
How can I fill the white space so even if one of the sizes has to overflow, it will only go up to 100px.
Is there a way to do this even if the original image is say, 100px x 100px or 150px x 200px, no matter which one, 100px is max, so one of the sides will have to give.
Thanks
You may find background-size css property interesting. Because this property does the same which you are trying to approach here. But this will work for background-image.
background-size: 100% 100%;
.rel-img-cont {
width: 100%;
height: 100%; }
.rel-img-cont img {
height:100%;
width:100%; }
Please see the demo
You can make width as 100% and leave the height to auto. And use only those img's which are proportionate to your div.
Use this code which is tested on my machine
<style>
.rel-img-cont
{
width: 10%; height: 10%; overflow: hidden;
border:3px solid orange;
}
.rel-img-cont img
{
height: 100%; margin:0 0 0 0;
width:100%;
}
</style>
Its better to use % instead of px in this case
<div id="Maindiv" style="width:100px;height:100px">
<img id="Img" src="http://blog.flattr.net/wp-content/uploads/2011/09/stackoverflow.png" alt="Image" />
</div>
CSS
#Maindiv img
{
width:100%;
height:100%;
}
What is the proper way to create responsive, transparent CSS captions over images — with graceful degradation in older browsers?
I am trying to achieve:
Centered vertical column of images
Images are equal heights and widths
Each image has a caption which should be centered
Caption should have a see-through background
Would be nice if the background became black in older browsers that don't support transparency
If you take a look at this Fiddle example, there's clearly a lot wrong with it.
The basic premise for HTML5 is:
<section>
<figure>
<img src="1.jpg">
<figcaption>Caption 1</figcaption>
</figure>
<figure>
<img src="2.jpg">
<figcaption>Caption 2</figcaption>
</figure>
<figure>
<img src="3.jpg">
<figcaption>Caption 3</figcaption>
</figure>
</section>
But the CSS3 code is where we get some problems. Is it the right approach even? I got it to work with some fine-tuning (not included), but the fine-tuning doesn't seem to make semantic sense to me anyway.
For example, this is the result:
I have a feeling the CSS is wrong on many levels (pun intended).
I modified your CSS slightly. The main changes were adding position: relative; to the parent element and position: absolute; to the caption.
CSS:
section {
overflow: auto;
}
section figure {
float: left;
clear: both;
position: relative;
overflow: auto;
margin: 0 auto;
padding: 30px 0 0 0;
font-size: 15px;
}
section figure img {
vertical-align: bottom;
}
section figure figcaption {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,0.7);
text-align: center;
color: #fff;
padding: 10px;
}
section {
padding-bottom: 30px;
background: #ccc;
}
Demo: http://jsfiddle.net/XjthT/6/