I am making an image slider and for some reason the parent element is adding whitespace at the bottom of parent div for no reason that I can tell. If there is a better way to set up the css then I would really appreciate a pointer. Here is the code:
HTML:
<div id="imgslider">
<ul class="bxslider">
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-11.jpg" alt="" />
</li>
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-1.jpg" alt="" />
</li>
</ul>
<div class="clear"></div>
CSS:
#imgslider {
display: block;
height: inherit;
}
.bxslider {
position: relative;
}
.bxslider img {
width: 100%;
max-height: 750px;
position: absolute;
}
.bxslider img:first-child {
top: 0;
left: 0;
z-index: 1;
}
There is a not closed div at the end :-)
Maybe this is what causing the issue:
<div id="imgslider">
<ul class="bxslider">
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-11.jpg" alt="" />
</li>
<li>
<img src="http://localhost:8888/wordpress/wp-content/uploads/2015/08/DevelopImages_PureTisanes_LowRes-1.jpg" alt="" />
</li>
</ul>
</div>
<div class="clear"></div>
Not sure it will help but i have read somewhere "clear:both" cause adding some space at bottom so you may want to add "overflow:hidden" to the parent div (i think it is the div with id "imgslider")
#imgslider {
display: block;
height: inherit;
overflow:hidden;
}
Related
I am trying to solve an issue. I have a regular list. Within the li's I have a overlapping div, witch appears on a hover. The problem is, that the hover is always overlapped by the next li. How can i make it happen, that the content of the next li stays below the hovered div. Html and css seems to stack li's? Is this a know problem?
I already tried z-index, but that will not work on child elements.
Its impossible to add the complete code, but this basically shows it. Why is the next li-element always overlapping the last and how can I get around this?
li {
position: relative;
width: 100px;
}
img {
width: 120%;
height: auto;
position: absolute;
top: 0;
border: 1px solid red;
}
<ul>
<li style="z-index:1;"><!-- list-element 1 -->
<div style="z-index:4;"><img src="http://img.brothersoft.com/screenshots/softimage/f/free_cat_wallpaper-407575-1285474870.jpeg" style="width:100%;" /></div>
</li>
<li style="z-index:1;"><!-- list-element 2 -->
<div style="z-index:4;"><img src="http://img.brothersoft.com/screenshots/softimage/f/free_cat_wallpaper-407575-1285474870.jpeg" style="width:100%;" /></div>
</li>
<li style="z-index:1;"><!-- list-element 3 -->
<div style="z-index:4;"><img src="http://img.brothersoft.com/screenshots/softimage/f/free_cat_wallpaper-407575-1285474870.jpeg" style="width:100%;" /></div>
</li>
</ul>
Thanks
/* EDIT: My Mistake - I misunderstood your question. */
Do the positioning on the .img-wrapper. (code snippet updated below too)
See this fiddle: https://jsfiddle.net/tqtveoau/4/
/* END EDIT */
I'm guessing this isn't your production code but always try and use classes for your styles.
.list-item {
position: relative;
width: 100px;
}
.img-wrapper {
display: none;
position: absolute;
top: 0;
z-index: 1;
}
.img-wrapper img {
width: 120%;
border: 1px solid red;
}
.list-item:hover .img-wrapper {
display: block;
}
<ul>
<li class="list-item">
List Item
<div class="img-wrapper">
<img src="http://img.brothersoft.com/screenshots/softimage/f/free_cat_wallpaper-407575-1285474870.jpeg" style="width:100%;" />
</div>
</li>
<li class="list-item">
List Item
<div class="img-wrapper">
<img src="http://img.brothersoft.com/screenshots/softimage/f/free_cat_wallpaper-407575-1285474870.jpeg" style="width:100%;" />
</div>
</li>
<li class="list-item">
List Item
<div class="img-wrapper">
<img src="http://img.brothersoft.com/screenshots/softimage/f/free_cat_wallpaper-407575-1285474870.jpeg" style="width:100%;" />
</div>
</li>
</ul>
See the fiddle here:
https://jsfiddle.net/tqtveoau/3/
Move the styles from your img to the parent div and give it a class. Also set the background of the div that's absolute to white
I am making an mobile web app, and I ran into this problem.
Currently my code is structured as follows:
<ul class="app-lst">
<li class="item-1">
<a href="#">
<img src="img1.jpg" alt="img">
</a>
</li>
<li class="item-2">
<a href="#">
<img src="img2.jpg" alt="img">
</a>
</li>
... etc.
</ul>
CSS:
.item-1 {
width: 90%;
height: 10%;
}
.app-lst li a {
background-color: red;
}
.app-lst li a img {
}
Below image is the result I am trying to get. As you can see from the code above, Each boxes are <li>, and under it, there is <a> and under the link there is the content.
How would I go about with this for CSS?
-Should i adjust the box's size by putting width and height on <li> or <a>?
-Should i set the box's color by putting background-color on <a>?
-And finally, the image does not adjust to fit inside the parent <a>, so it extends the whole box if the image is larger. I tried putting "max-width: 100%" on the image, but no luck.
Also, since it is a mobile design I am controlling all the sizes with percentages. is this a good practice or should I do it with pixels?
Thank you so much in advance for your help!
You will need to use your <ul> as a container that is set to 100% height/width, and then size your <li> elements based on that. Then finally, make your <img> elements 100% height and width.
HTML
<ul class="app-lst">
<li class="item-1">
<a href="#">
<img src="http://placehold.it/150x150" alt="img"/>
</a>
</li>
<li class="item-2">
<a href="#">
<img src="http://placehold.it/150x150" alt="img"/>
</a>
</li>
<li class="item-3">
<a href="#">
<img src="http://placehold.it/150x150" alt="img"/>
</a>
</li>
<li class="item-4">
<a href="#">
<img src="http://placehold.it/150x150" alt="img"/>
</a>
</li>
<li class="item-5">
<a href="#">
<img src="http://placehold.it/150x150" alt="img"/>
</a>
</li>
</ul>
CSS
.app-lst {
display: block;
height: 500px;
list-style-type: none;
margin: 0;
padding: 0;
}
.app-lst li {
display: inline-block;
float: left;
margin: 0;
padding: 0;
}
.item-1, .item-2 {
height: 75%;
}
.item-1 {
width: 75%;
}
.item-2 {
width: 25%;
}
.item-3, .item-4, .item-5 {
height: 25%;
}
.item-3 {
width: 10%;
}
.item-4 {
width: 20%;
}
.item-5 {
width: 70%;
}
.app-lst li img {
height: 100%;
width: 100%;
}
JSFiddle: http://jsfiddle.net/b6x1byfp/
I am new to html,css and am currently working on a page.
I am unable to align the menu at the right bottom side.It is clashing with my 3 pictures in the middle. Also logo at the bottom left keeps changing when ever I make changes to the images at the centre. Kindly go through the code and let me know.
body {
margin: 0;
padding: 0;
}
.background{
position: relative;
}
.background .text {
position: absolute;
top: 300px;
left: 300px;
width: 300px;
}
.logo {
position:absolute;
left: 10px;
bottom: 10px;
}
#bottomnav ul {
list-style: none;
display: inline-block;
width: 100%;
position: absolute;
right:0px;
bottom:0px;
}
#bottomnav ul li {
width: 0%;
float: right ;
text-align:right;
}
.images{
width:250;
height:250;
display:inline;
float:right;
border:2px solid #FFF;
margin-top:300px;
}
<body>
<div class="background">
<img src="images/landing_page.png"/>
<div class="text">
<h1>welcome</h1>
<p>office</p>
<p>ink</p>
</div>
<div class="logo"> <img src="images/logo_03.png"/> </div>
<div class="images">
<img src="images/top1.jpg" width="400" style="float:right"/>
<img src="images/top2.jpg"width="400" style="float:right"/>
<img src="images/top3.jpg" width="400" style="float:right"/>
</div>
<div id="bottomnav">
<ul>
<li>Home</li>
<li>About </li>
<li>Contact Us</li>
</ul>
</div>
</div>
</div>
Divi,
check out clearfix.
http://nicolasgallagher.com/micro-clearfix-hack/
You will need to apply the fix to the image parent container (.images).
Also you are using a lot of absolute positing, when it is not necessarily needed.
You could float the logo left and image container right, while applying an explicit width to each.
Also why do you have .images set to 250 width, and images are 400 width?
I am unsure if this is the answer you're looking for, but this solution solves the problem you were having regarding the menu not showing up on the bottom right hand side (I think is what you were trying to achieve with some of your css): http://jsfiddle.net/swm53ran/72/
I reorganized the structure of your html a little bit because you said the logo should be at the bottom (I'm assuming below the other larger pictures).
<div class="background">
<img src="images/landing_page.png"/>
<div class="text">
<h1>welcome</h1>
<p>office</p>
<p>ink</p>
</div>
<div class="images">
<img src="images/top1.jpg" width="400" style="display:inline-block;"/>
<img src="images/top2.jpg"width="400" style="display:inline-block;"/>
<img src="images/top3.jpg" width="400" style="display:inline-block;"/>
</div>
<div class="logo"> <img src="images/logo_03.png"/> </div>
<div id="bottomnav">
<ul>
<li>Home</li>
<li>About </li>
<li>Contact Us</li>
</ul>
</div>
</div>
heres the css:
#bottomnav {
display:inline-block;
float:right;
}
#bottomnav ul {
list-style: none;
}
#bottomnav ul li {
display: inline-block;
}
Useful tip: when dealing with css, less is more, try to be concise in your styles so that you dont have to write over styles with other styles and force your way around the DOM.
hope this helps/gets you pointed in the right direction.
I can't for the life of me get a set of images to line up on screen horizontally.
#full_image {
margin: 0;
padding: 0;
list-style: none;
white-space: nowrap;
overflow: hidden;
position: absolute;
}
#full_image ul li img {
display: inline;
margin: 0 auto;
width: 100%;
max-width: 100%
}
<div id="full_image">
<ul>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
<ul>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
<ul>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
</div>
You're creating a new list with each image, for starters; and each list is a block-level (not inline) element. Block elements start on a new line, by default.
Then, your display: inline is applied to the images, not to the li that contains them, which is still at block level.
Finally, list-style: none doesn't make sense on a div. I assume you mean to apply it to a list.
So:
#full_image {
margin: 0;
padding: 0;
list-style: none;
white-space: nowrap;
overflow: hidden;
position: absolute;
}
#full_image li {
display: inline;
}
#full_image li img {
margin: 0 auto;
max-width: 100%
}
<ul id="full_image">
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
<li>
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</li>
</ul>
remove tags ul li and try again
Remove the list tags
http://jsfiddle.net/cxfNb/ they line up fine. If you want the bullet points, you'll have to remove the block style of the ul and li tags
<div id="full_image">
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
<img src="http://i.telegraph.co.uk/multimedia/archive/01636/saint-tropez-beach_1636818c.jpg" alt="" />
</div>
I have a menu like
but would like to get a resultlike this
So far I have this:
<div id="bottomnav">
<ul>
<li>
<a href="#" target="_blank" title="lamp">
<img class="swing" src="http://site.cheetos.com.br/static/masterbrand/img/cap1-poste.png" width=250 height=350 style="z-index: 10" />
</a>
</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
I added z-index, but I am doing it wrong, What can it be done to put the image above the menu?
please take a look at the fiddle
Aligning Multiple Images In a Fixed Footer
You want something like this:
#bottomnav{
width: 100%;
height: 50px;
background: no-repeat url(http://eurekavi.com/barraroja.png);
background-size: 100% 100%;
position: absolute;
bottom: 0px;
}
#bottomnav ul {
width: inherit;
height: inherit;
list-style: none;
}
#bottomnav ul li {
width: 25%;
height: inherit;
position: relative;
float: left;
outline: 1px solid yellow;
}
#bottomnav li img {
position: absolute;
bottom: 0;
left: 0;
}
where you HTML looks like:
<ul>
<li>
<img ... />
</li>
<li>
<img ... />
</li>
<li>
<img ... />
</li>
</ul>
Fiddle: http://jsfiddle.net/audetwebdesign/s5GNA/
Some Explanation
Your bottomnav parent container is absolutely positioned at the bottom, that is fine.
For ul and li, inherit the height so as to take the guess work out of where the bottom of the elements are (when you float the content, the heights will collapse otherwise).
For li, you must set the position to relative and float them left.
Finally, absolutely position the images left and bottom to 0.
If you can, make your images all of the same dimensions and adjust the lamp bases so that they have a common baseline, otherwise, you need to tweak the bottom: {n}px setting for each image where '{n}' is some number to be found by trial and error.