I want to have multiple images on the same line with a caption below each image.
I can put images on the same line using the display:inline tag. When I add the figure tag, they are moved to different lines.
I tried multiple variation and can't get it to work.
Am I using the wrong tags for the job? I've seen this on other sites, but don't know how they do it.
CSS
section.products{
width: 100%;
padding:5px;
line-height:100%;
margin-top: 5px;
float: left;
text-align: center;
}
img.fans {
text-align: center;
max-width: 100%;
height: 50px;
width: 50px;
}
a {
color: #000000;
text-decoration: none;
font-weight: bold;
}
p {
text-align:center;
align: center;
}
figure {
display:center;
}
ul.fans li{
display: inline;
}
HTML
<section class="products">
<h1>Fans</h1>
<p>
<ul class="fans">
<li>
<a href="#">
<figure>
<img class="fans" src="images/shrouded.JPG" alt="Shrouded" style="Float"</img>
<figcaption>Shrouded</figcaption>
</figure>
</a>
</li>
<li>
<a href="#">
<figure>
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" style="Float"</img>
<figcaption>Shallow Recess</figcaption>
</figure>
</a>
</li>
</ul>
</p>
</section>
You've got a couple things wrong.
You didn't close your image tags properly
you have in inline style of "float" which is not valid
This should help get you what you're looking for.
Css
ul.fans li {
display: inline-block;
}
figcaption {
text-align: center
}
Html
<section class="products">
<h1>Fans</h1>
<p>
<ul class="fans">
<li>
<a href="#">
<figure>
<img class="fans" src="http://placehold.it/300/300" alt="Shrouded"/>
<figcaption>Shrouded</figcaption>
</figure>
</a>
</li>
<li>
<a href="#">
<figure>
<img class="fans" src="http://placehold.it/300/300" alt="Shrouded" />
<figcaption>Shallow Recess</figcaption>
</figure>
</a>
</li>
</ul>
</p>
</section>
Codepen Example
with html 5 the proper way to put an image tag is like so
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" />
You dont need a tag because you never finished opening the tag, it seems like you are mixing the old way of doing things like this
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded"></img>
display inline will make the li act as if they are a p tag or any other inline element.
The reason they are going to new lines when you add a figcaption is because figcaptions are display: block. block display types will always push items to the next line. with css you can change the display types of items like you did with the li elements.The figure tag is also a block element.
when you write html please always indent when there is nesting (an element inside of another one)
Also the style="Float" is not valid css. anything in between the "" will be css and it is called inline css. It is best to not have css inline because it can cause problems when trying to change the css the majority of elements later on.
you can add css in the top of your document with the style tag. like so
<style type="text/css">
ul.fans li {
display: inline;
}
</style>
You will want to correct the closing tag and get the css in the right spot, and make sure you do not do inline css (style="float:left;").
Since stated from the answer before that you probably don't need a list for this because lists are for breaking into new line, you will probably want to do something like this instead
<style type="text/css">
.fans li{
display: inline;
}
.fans .captioned-image {
display:inline-block;
width:200px;
}
.fans figure {
width: 200px;
display:block;
text-align:center;
}
img {
max-width:200px;
}
</style>
<section class="products">
<h1>Fans</h1>
<p>
<div class="fans">
<div class="captioned-image">
<a href="#">
<figure>
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" style="" />
<figcaption>Shrouded</figcaption>
</figure>
</a>
</div>
<div class="captioned-image">
<a href="#">
<figure>
<img class="fans" src="images/shallow_recess.JPG" alt="Shrouded" style="" />
<figcaption>Shallow Recess</figcaption>
</figure>
</a>
</div>
</div>
</p>
</section>
Related
Say I want my web page display things like this, but I want to use <figure> tag.
The problem is that simply attach the style on to the <figure> is not a perfect way.
For example, if add circular, then both of the <img> and <figcaption> will be "circulared".
<figure class="ui small right floated image circular">
<img src="/img/here.jpg">
<figcaption>Caption here...</figcaption>
</figure>
caption of the picture is "circulared" too
Can semantic-ui work like this:
<figure class="ui right floated">
<img class="image small circular">
<figcaption class="something else">
kind like inheritance?
I hope this will solve your problem with img tag and div let me know if any doubt check this code pen https://codepen.io/anon/pen/OdqKLy
html
<div class="card">
<div>
<img class="ui image circular" src="https://sample-videos.com/img/Sample-jpg-image-500kb.jpg">
</div>
<div>
Caption here...
</div>
</div>
CSS
.card {
width: 180px;
margin: 10px;
padding: 0px 10px;
text-align: center;
}
This answer is inspired by this answer.
CSS
<style>
[class*="left floated"] {
float: left;
margin-left: 0.25em;
}
[class*="right floated"] {
float: right;
margin-right: 0.25em;
}
figcaption[class*="centered"] {
margin-left: auto;
margin-right: auto;
text-align: center;
display: block;
}
</style>
Then, if you want to right float or left float the whole <figure>, just add it to the class, like below:
<figure class="right floated">
<img class="ui small bordered centered circular image" src="image.png">
<figcaption class="centered">
Caption here...
</figcaption>
</figure>
If you want the whole <figure> be centered, just leave the <figure> class blank, and the browser will render it to "center float" by default. But the centered in <img> is still necessary.
I have three images, the firsts are the brazilian flag and the english flag (language settings).. and the third is the logo of my site...
code:
<a class="language" href=""><img src="assets/images/language/portuguese.png">Português</a>
<a class="language" href=""><img src="assets/images/language/english.png">English</a>
<img class="logo" src="assets/images/logo.png">
I want the first and the second above the third..
So, in my css i made:
.language {
margin: 0 5px 0 10px;
}
.logo {
width: 40%;
margin-top: 60px;
}
There is something wrong?? it's not working.
At the moment you have all three images in the same "row". You didn't separate them in two rows in any way.
I would suggest putting language icons in their own div tag like this:
<div>
<a class="language" href=""><img src="assets/images/languag/portuguese.png">Português</a>
<a class="language" href=""><img src="assets/images/language/english.png">English</a>
</div>
<img class="logo" src="assets/images/logo.png">
More information missing from your question, but I guess that's it
<style type="text/css">
.classe1 {
background-image: url('../../Content/images/carousel2.jpg');
background-repeat: no-repeat;
height:100px;
}
</style>
<div class="classe1">
<img src="../../Content/images/Icon1.png" alt="" width="40px" />
<img src="../../Content/images/Icon2.png" alt="" width="40px" />
</div>
If you can't influence the HTML, you can make <br> with CSS:
a + a:after {
content: "\A";
white-space: pre;
}
Since ::before and ::after don't work on self closing tags like <img>, you'll have to add it to the second <a>
Voila demo
Just make it like this
HTML
<div class="wrapit">
<a class="language" href=""><img src="assets/images/language/portuguese.png">Português</a>
<a class="language" href=""><img src="assets/images/language/english.png">English</a>
<img class="logo" src="assets/images/logo.png">
</div>
CSS
.wrapit {
width: 100px;
float: left;
}
.wrapit img { width: 100%; float: left; }
.wrapit a { float: left; width: 50%; display: block; }
Hey guys i am working on this gallery.
Now I've thumbnails set on block grid and ive added an overlay div on first list item and the problem is that i am not able to set it dynamically i mean 100 percent width and height because the gallery is responsive so what i wanted is that overlay should fix on thumbbs.
i am unable to set the fiddle so i am uploading a live example.
you can see overlay extending thumbs.
please suggest a solution
Link
Thanks.
I need overlay on every thumb.
Here is my Code new one
<style>
.thumbsList li {
position: relative;
}
.overlay
{
position: absolute;
z-index: 22;
background-color: black;
opacity: 0.6;
height:100%;
with:100%;
z-index: 22;
}
</style>
</head>
<body>
<div class="row projectsRow">
<ul class="large-block-grid-3 medium-block-grid-3 small-block-grid-2 thumbsList">
<li >
<div class="overlay"></div>
<img class="projectsThumbs" src="img\projects\1.jpg" alt="">
</li>
<li >
<div class="overlay"></div>
<img class="projectsThumbs" src="img\projects\2.jpg" alt=""></li>
<li >
<div class="overlay"></div>
<img class="projectsThumbs" src="img\projects\3.jpg" alt=""></li>
</ul>
</div>
<script src="js/jquery.js"></script>
<script src="js/jquery.nicescroll.min.js"></script>
<script src="js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
Give a position: relative; to the your <li> elements. Also put the <div class="overlay"></div> tag inside each <li> tags.
.thumbsList li {
position: relative;
}
And put the following code inside all <li> instead of just the first one.
<div class="overlay"></div>
I have the following HTML:
<span class="wrapper">
<img src="..." />
Some text!
</span>
How can I hide the text, but not the image, when the text doesn't have it's own tag?
Position relative, perhaps:
<span class="wrapper">
<img src="http://www.placehold.it/100" />
Some text!
</span>
.wrapper {
position: relative;
left: -9999px;
}
.wrapper img {
position: relative;
left: 9999px;
}
Demo
There's only so much CSS can do.
.wrapper {
color: transparent;
}
I suppose you can mess with font sizes and families if you really wanted to but that's just messy.
try used text-indent to hide the text
.wrapper {
text-indent:-5000px;
}
or span the text and have a unique class and display:none
html
<span class="wrapper">
<img src="..." />
<span>Some text!</span>
</span>
css
.wrapper span {
display:none;
}
Semantically, your code is not proper. You are inserting an inline-block element(inline behaving as a block) within an inline element (span).
You can have following markup and make it easy:
<p>
<img src=""/>
<span></span>
</p>
And then easily hide the span. :)
I do not know how to describe the problem, hence please visit the link.
In this (A), the white background is rendered nicely, but if I added
<!-- Problem here -->
<ul class="thumb2"><li>
<a href="/malaysia/ceiling-lights/8044-f610-255" title="">
<img src="https://lh5.googleusercontent.com/_8Uc0MYA0xgM/TXQ-BvHi-uI/AAAAAAAAAL4/vgYnsHjUziU/s220/8044f610255.jpg" title="" alt="" /></a>
</li></ul>
<!-- Problem here end -->
Then the page become (B), the white background disappears.
How do I solve the problem?
The problem is that all of the thumbnails are "floated." See the CSS "float" property. Floated elements do not take up page space. To fix that, you can use some sort of CSS "clearfix" after all of the thumbnails.
The quickfix for this is to add:
<br style="clear: both;" />
After all of your thumbnails.
Another option is something like:
.spacer
{
clear: both;
height: 0;
line-height: 0;
font-size: 0;
}
And then you can add:
<div class="spacer"></div>
Nowadays, crazy hip developers are using something like:
http://www.webtoolkit.info/css-clearfix.html
just add
<div style="clear: both;"> </div>
after the </ul>
The problem you are having has to do with your floated image elements. CSS can have difficulty calculating the height of a div that contains floated elements.
JUST Replace your current code with the below codes. It will 100% work
<style type="text/css">
.clearfix {
clear:both;
}
</style>
<ul class="thumb2"><li>
<a href="/malaysia/ceiling-lights/8044-f610-255" title="">
<img src="https://lh5.googleusercontent.com/_8Uc0MYA0xgM/TXQ-BvHi-uI/AAAAAAAAAL4/vgYnsHjUziU/s220/8044f610255.jpg" title="" alt="" /></a>
</li>
</ul>
<div class="clearfix"></div>