you want the container to shrink or expand when you click next?I have created one fiddle here: http://jsfiddle.net/agriz/nS8M3/1/
I am forced to give height for these two elements <div class="slider"> <ul>
I would like to have automatic height for these two containers.
If we mix relative and absolute positions, is it possible to have dynamic height for the containers?
I searched in SO and found this one: http://jsfiddle.net/ambiguous/zVBDc/
Here too the container has the height property in css.
HTML PART
<div class="slider">
<ul>
<li class="active"><img src="http://i41.tinypic.com/10rok86.jpg" class="slider_img" /> </li>
<li><img src="http://i40.tinypic.com/f0rfag.jpg" class="slider_img" /></li>
</ul>
</div>
<div class="toolbars">
<button onClick="window.slider.previous()">Previous</button>
<button onClick="window.slider.next()">Next</button>
</div>
I want the container to shrink or expand when I click next (copied from a comment!)
See fiddle for possible answer. http://jsfiddle.net/zGpKa
I made the following change to your CSS.
.slider li {
position: relative;
margin: 0;
padding: 0;
left: 0;
display: none;
}
Related
I have been trying to create a specific layout for some images. Layout I would like to create.
I have tried floating the smaller images so that they stand alongside the large image, this works if I add a clearfix but then for some reason the width I apply to the images is no longer effective. So it's either large images in the right positioning or small images all over the place.
I tried putting all images into separate div tags and then a parent div, then floating but that has it's own issues.
Can this be done in HTML & CSS or do I need to be going down the jQuery route?
I will be tidying the code up, I'm just trying to get it right in my head atm.
HTML:
<section id="galleryposition">
<ul id="gallery">
<div id="mainimage">
<li>
<a href="img/8.jpg">
<img src="img/8.jpg" alt=""></a>
</li>
</div>
<div id="smallphotos">
<div id="smalllefttop">
<li>
<a href="img/2.jpg">
<img src="img/2.jpg" alt="">
</a>
</li>
</div>
<div id="smallrighttop">
<li>
<a href="img/3.jpg">
<img src="img/3.jpg" alt="">
</a>
</li>
</div>
<div id="smallleftbottom">
<li>
<a href="img/4.jpg">
<img src="img/4.jpg" alt="">
</a>
</li>
</div>
<div id="smallrightbottom">
<li>
<a href="img/5.jpg">
<img src="img/5.jpg" alt="">
</a>
</li>
</div>
</div>
</ul>
</section>
CSS:
#gallery {
margin: 50px 0 0 0;
padding: 0;
list-style: none;
}
#galleryposition {
text-align: center;
}
#gallery img {
border-radius: 2.5%;
}
#gallery li {
float: left;
margin: .5%;
color: #bdc3c7;
}
#gallery li a p {
margin: 0;
padding: 5%;
font-size: 0.75em;
color: #bdc3c7;
}
#smalllefttop group {
max-width:50%;
float:left;
}
#smallrighttop group{
max-width: 50%;
float:right;
}
#smallleftbottom group{
min-width:50%;
float:left;
}
#smallrightbottom group{
min-width:50%;
float:right;
}
https://jsfiddle.net/apdeng/wyvzmm9q/1/
Thanks in advance.
Ok, so I started to play around with your code, but I was basically just re-starting it for you, which isn't what SO is for, so here are some things you need to consider:
<ul> tags are intended for lists. This definition is often stretched by developers who use them to create a "list" of links used for navigation, but in this case your image layout is complicated by the use of the <ul> and <li> structure. You'd be better served by simple <div> tags, which a) don't require both the <ul> and <li> tags and b) make more sense semantically since this is not, in fact, a list.
It's bad practice to put a <div> inside a <ul> like your #mainimage div.
The selector group in your css isn't actually doing anything. I googled this because I've never seen it before and couldn't come up with what purpose that keyword would serve. The elements followed by "group" aren't getting the styles you're trying to apply to them. I would remove that from your css.
You'll have more success with just plain old width in your css (not max-width)
Never use <br> tags to create space in a layout. Use margins and padding instead.
Make sure all your tags are closed and opened. When JSfiddle highlights the text red, that means you're missing part of a tag. (In your case, you have one too many </a> tags in each group.)
What you basically need to do is clean up your markup as much as you can and make that big image roughly 50% width and each of the other images roughly 25%. I say roughly because when you go to add margin between all of them, your total width will still need to add up to 100% (any more than that and some of your elements will bump down to the next line). That's probably what went wrong when you tried adding width to your images. Look at selectors for nth-child or last-child to help you remove the margin on the blocks on the side.
Let me know if you have more questions!
I am following my previous question that has two boxes, that have two images (can be vertical or horizontal), the issue is the height of boxes are fixed and when I change the window screen in some screen sizes the images bypass the border of the boxes.
I checked answers of these questions 1 and 2 but did not help much.
DEMO
CSS
.items { */
position: relative;
margin-bottom: 7px;
margin-left: 7px;
margin-right: 0px;
text-align: left;
background-color: red;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
border-bottom-left-radius: 20px;
padding-left: 1%;
height:260px;
}
.col-md-12.col-xs-12.btn>a>img {
float: right;
width: 100px;
height: 50px;
}
.col-md-12.col-xs-12.my-col {
padding-left: 100%;
}
.my-row {
bottom: 0;
padding-right: 0;
position: absolute;
}
.my-row {
bottom: 0;
padding-right: 0;
position: absolute;
}
.btn {
float: right;
bottom:0;
margin-right:-12px;
margin-bottom:-6px;
position:absolute;
right:0;
}
HTML
<div class="container-fluid">
<div class="row">
<div class="col-md-3 items">
<div class="row">
<div class="col-md-12 text-center">
<h4>T1</h4>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<h5>T2</h5>
</div>
</div>
<div class="row">
<div class="col-md-12 row text-center">
<a
href="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
title="T1" data-gallery rel="nofollow"> <img
id="imageresource"
src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
class="img-thumbnail" width="30%" style="margin-left: 30px;" />
</a>
</div>
</div>
<div>
<img src="#" class="btn" />
</div>
</div>
<div class="col-md-3 items">
<div class="row">
<div class="col-md-12 text-center">
<h4>T1</h4>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<h5>T2</h5>
</div>
</div>
<div class="row">
<div class="col-md-12 row text-center">
<a
href="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
title="T1" data-gallery rel="nofollow"> <img
id="imageresource"
src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong"
class="img-thumbnail" width="25%" style="margin-left: 30px;" />
</a>
</div>
</div>
<div>
<img src="#" class="btn" />
</div>
</div>
</div>
</div>
</div>
First off, the markup is over complicated for what you want and line 15 and 45 are applying bootstrap classes .col-md-12 and .row on the same element which is in incorrect. Bootstrap class .col-xx-nn must be assigned to a child element with a bootstrap class .row.
Getting back on track to what you want. I have simplified the HTML code to get your desired result, I think. Check it out and let me know what isn't right and I will change it and explain why.
https://jsfiddle.net/6y4uf16y/84/
What I did was create a container div around the sale image that uses the CSS flex box. This div will take up any remaining space. Therefore, if you change the height of your .items element. The flexbox container will adapt and the sale image will respond appropriately to the new size. There is no fixed heights here except for the one that was placed on the .items class of 260px which I believe is what you wanted.
The reason for this is that the bootstrap class .img-reponsive needs a height and/or width attribute to be responsive. Therefore, I have set the height and width equal to the flex box container around it. You can change the width value or .img-sale back to 30% if you wish.
Moreover, as a bonus, I have aligned the button to always be in the bottom right corner as I think you wanted it.
If this answer solves your problem, don't forget to mark it as the correct solution.
Cheers
Edit Sorry wrong JSFiddle link, correct link has been added. I also added proof that it is dynamic with multiple rows of text in the h4 and h5 elements.
You have to add class
.col-md-12 >a>img.btn {
float: right;
width: 100px;
height: 50px;
}
because .col-md-12.col-xs-12.btn>a>img is not applying to any of your given HTML div content
Is it a design requirement that the images get wider as the boxes get wider? If so, the only way to keep the images within the boxes is to increase the height of the boxes as you increase the height of the images.
If it's not a requirement that the images scale up, then you can see my solution here: http://jsfiddle.net/6y4uf16y/75/
All I did was remove the explicit widths from your images (the first was width="25%" and the second was width="30%") and instead used CSS to control the scale by limiting the max-height of the images. .items img {max-height:100px;}.
Since you have a fixed height and need to keep the images inside the boxes, you know for a fact that also have a fixed maximum height on the images
I am not sure if you can have line break on T1 & T2, otherwise you can do this
img{
max-height:170px;
width:auto
}
DEMO
i agree with #Bhavin Solanki and may be the one thing i will suggest that try to give the
width: 100px;
height: 50px;
in to percentages Or else you can go with Media queries for the particular image selectors that will help you to manage a lot
Your HTML Bootstrap code isn't totally correct:
You can't nest a .col-md-12 class inside a .col-md-3 class not
in my knowledge at least.
Your .rows classes are not always well positioned within the code
see the fiddle link that i prepared below.
I tried to do my best to understand what you want to achieve with your code i also ordered tags within your code so that your divs fit the window size regardless of its width.
EDIT
Try to define the width of your image with vw unit (width:15vw;) That will keep the image from crossing the containing item.
I illustrated an example for you here :
http://jsfiddle.net/merhzqwg/65/
Hope it helps.
OK this is the thing, your code is not very clean. there are some errors as well
for eg: you have used the id="imageresource" twice. An id can ONLY be used once on a single page. Very Important.
but i will provide a quick fix for this.
by default bootstrap adds max-width: 100%; height: auto; to the class img-thumbnail to override that what i have done is i have added a class to both of the images img-sale.
<img class="img-thumbnail img-sale" id="imageresource" src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQKWYNnGt8d9G1sf8PE0TpOglpZ2dKnHWAP5FB_spYgelcToong" width="30%" style="margin-left: 30px;" />
and added the following css:
.img-sale {
max-height: 170px;
width: auto;
}
http://codepen.io/anon/pen/OVwrpJ?editors=110
http://jsfiddle.net/6y4uf16y/82/
but the rest of the code is not recommended to proceed with.
I am trying to display navigation items (horizontally) in a blue colored ribbon. Somehow, the background-color property is not getting applied to the ul element. I tried to put it inside a div element with background as blue. Still, it doesn't work
Html snippet as,
<div style="background-color:blue;">
<ul style="list-style-type:none;background-color:blue;">
<li style="float:left;margin-right:10px;">cassandra</li>
<li style="float:left;margin-right:10px;">mongodb</li>
<li style="float:left;">couchdb</li>
</ul>
</div>
Why is my background color not showing if I have display: inline?
This is the same issue as this. The div is coming out at height 0, same as the list as the float doesn't take up any space.
If you specify the height or tell them to display:inline-block it'll work.
Fiddle: http://jsfiddle.net/7vp4vz6f/
You are using float property for the li elements, so you need to apply some sort of clearfix for container to adjust it's size according to the content size. You can try with the overflow CSS property:
body > div { overflow: auto}
JSFiddle
<div style="background-color: blue; overflow: hidden;">
<ul style="list-style-type:none;background-color:blue;">
<li style="float:left;margin-right:10px;">cassandra</li>
<li style="float:left;margin-right:10px;">mongodb</li>
<li style="float:left;">couchdb</li>
</ul>
</div>
Your elements have no width and height, that's why.
Also, consider using a stylesheet, one of the many advantages is that you don't run into such issues very often.
This question already has answers here:
How can I wrap text around a non rectangular image?
(5 answers)
Closed 3 years ago.
I am trying to get an image of mine to float in the center of a div. Code currently:
<style type="text/css">
#navig {
height: 333px;
}
#navig img {
display: block;
margin: 0px auto;
}
</style>
<div id="navig"><img src="images/logo.png" height="333" id="logo" /></div>
The trouble is the image is a diamond and I would like the text to wrap around the diamond with the indents. I believe this is a possibility with <img align='center' /> but this was deprecated in HTML 4.01 and not even supported in HTML 5.
I have tried several possibilities and I still cannot get the text to wrap correctly around the diamond.
Refer to this for some options. I have two options, CSS-Shapes and SVG.
The best option current is to use an SVG image but make sure to use the SVG code and not linking it as an image.
Here is a JSFIDDLE, as you can see the text is able to highlight and can be edited. (More of a pain to edit so do your best with the text in AI before saving but it can still be edited)
This is also very flexible as you can see in this FIDDLE.
This is a very new feature and does not have good browser support yet.
SO CSS-Shapes
Once this,
shape-outside: polygon(50px 0px, 100px 100px, 0px 100px);
is supported you will be able to do this with ease.
I recommend learning the basics so once it is supported by most current browsers you will already know what to do.
I managed to figure out a manual way around this. The image remains in the div and is surrounded by two other closed divs tags.
<div id="navig">
<div id="nav1"></div>
<div id="nav2"><img src="images/logo.png" height="333" id="logo" /></div>
<div id="nav3"></div>
</div>
I then make sure all three of these float left: #navig div {float:left;} and the two empty divs are using text-align. The first one will align right and the last one align left.
The two empty divs are then filled with <ul>s and the menu I wanted around it is filled into the <li> tags. For the examples I'll use some basic menu items.
<div id="navig">
<div id="nav1">
<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
<div id="nav2">
<img src="images/logo.png" height="333" />
</div>
<div id="nav3">
<ul>
<li>Products</li>
<li>Shipping</li>
<li>Legal</li>
</ul>
</div>
</div>
I then added #nav1 ul li:nth-child(1) and positioned the first element, which would be "Home" against the diamond. I can change "Home" to whatever I fancy and the position remains as it is forced to text-align: right. Adding these with however many <li> items you are using and editing them to suit your needs. For example:
#nav1 ul li:nth-child(1) {
position: relative;
left: 48px;
}
#nav1 ul li:nth-child(2) {
position: relative;
left: 24px;
}
#nav1 ul li:nth-child(3) {
position: relative;
left: 8px;
}
This pushed my first, second and third items over to the diamond but with a little padding so as to not intrude.
A bit of a lengthy process, but plenty of freedom and has given me the desired effect!
You can't do it with just an image.
But you can use shapes, check this page:
https://www.makeuseof.com/tag/csstextwrap/
Using CSSTextWrapper you can easily generate HTML text wraps for any
imaginable shape. It can be circles, zig-zags, triangles or whatever
you want. Quick and simple-to-use, just load the logo (optional) on
the provided dashboard and drag sidelines to define your text wrap.
Quite impressive.
I have a footer that has 3 elements within it as follows:
<div class="footer">
<div class ="jumperMenu">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
<div class ="logo">
<img src="#"/>
</div>
<div class ="navJumpMenu">
<ul>
<li>Page1</li>
<li>Page2</li>
<li>Page3</li>
</ul>
</div>
The footer div needs to have a max width of 1600px,i need the JumperMenu to stick to the left of the footer, logo to be in the centre and navJumpMenu to stick to the right, right and left elements need 10px padding..
All is fine with floats - The issue I have is that I need all the elements to also move within their positions on smaller screens - so say the screen was only 1200px i need the 3 elements to stick to their respective layout positions but adjust to fit within the screen size.
Does anyone have any idea at how to accomplish this with pure CSS - so I dont have to resort to a jquery positioning?
Cheers
http://jsfiddle.net/calder12/KjG8v/1/
.footer{max-width:1600px; margin:0 auto;text-align:center;}
.jumperMenu{float:left;}
.navJumpMenu{float:right;}
.logo{margin:0 auto;}
You'd probably want to set a minimum width on the footer container too to make sure the 3 elements don't actually run over each other, but I think that's what you want isn't it?
Is this what you are looking for?
#footer {
display: inline-block;
max-width: 1600px;
min-width: <your min width>;
text-align: center;
}
#footer>* {display: inline-block;text-align: left;}
#footer #navJumpMenu{float:right;}
#footer #jumperMenu{float:left;}
Hope that helps.