So basically I have in my HTML(using bootstrap classes) a page with products that are showcased using the thumbnail and caption classes. Over the picture of the products there is a ON SELL(rounded red tag). I have given to this red circle element position absolute and to the col-sm-9 position relative. Problem is that when I resize the browser the ribbon that comes over the thumbnail is not responsive.
I know what this two positioning properties mean and how they work in respect with each other. But it looks that in practice I`m missing on something very essential.
I will paste my html and css over here and if you can give me your opinion I`ll be very glad to learn this the proper way and give you my thanks :)
Here you have the whole code: http://www.bootply.com/8TMS5WgWt2
In your CSS for .sale change your positioning value of left: 149px to right: -19px. This will help it better position as the width changes. I would also recommend moving your position: relative off the .col-sm-9 and onto .thumbnail
In your css, replace left for right
top: -19px;
left: 149px;
With left, always it calculate from left position.
top: -19px;
right: yourpixels;
Here is an example with right: 0px
http://www.bootply.com/EzRZnhA2EC#
Related
I would like to do this from my website here: http://project.jazzassite.tk
and be able to place the contents into a div that I can center or do whatever I want with them. The only problem is, If I float it, it doesn't work, and if I use position:relative They create a stair case effect.
I was hoping I would be able to do this purely with CSS, and not use any tables, ect.
Any help appreciated,
Jazza
Are you wanting to center the navigate div which contains all the 6 children? If so, this should work:
#navigate {
position: absolute;
top: 50%;
left: 50%;
margin-left: -540px;
margin-top: -15px;
}
The margin-left is the half the width of the contents and then made negative. The margin-right is half the height of the contents and then made negative. This will vertically and horizontally center your objects. Is this what you're looking for or did I miss the point?
I'm trying to set up a responsive header that takes an image and resizes it to the browser – easy enough. What I can't manage to achieve is centring the image vertically within it's container (in this case an a element)
See example:
http://jsfiddle.net/jwoodcreative/tUW3k/
I've tried a few css tricks that havent worked and some jQuery. Either type of solution would suit if anyone knows of one.
You can always use the top:50%, bottom: 50% trick like here: jsfiddle v13
.outerElement {
position: relative;
height: XXpx;
top: 50%;
}
.innerElement {
position: absolute;
bottom: 50%;
}
This works, because the height of the innerElement is not the same as the one of the outer Element, so you can center your element (if the heights were identical, you'd just position it to pos:0 again)
Like this? I've changed the image to be a background-image, which can be centered very easily in CSS. To make sure the link is shown, I have added a non-breaking space ( ). I think this is what you want, right?
You can change the appearance of the image more by looking here, at the documentation of the background property.
I'm trying to place an img to the bottom of the outer div.
Sadly it is not working as the default styles from wordpress are making it impossible...
My Project
The img I'm talking about is the small image on the left next to the big main one...
I would appreciate any help as this is already driving me crazy for hours!
Any help is appreciated!
Thanks
edit:
Here's a picture of what it should look like later:
It would help if you posted a picture of what you want the end result to be, but to put an element at the bottom of a container the usual way is setting it's style to something like position: absolute; bottom: 0 you can put a small value in bottom: to offset it a bit to match, you can then use left or rightto set the offset with the other limits of the container.
Edit: I tried this code in the img tag with firebug, seemed to work like in your picture:
element.style {
bottom: 90px;
position: absolute;
right: 350px;
}
I am doing a page where I show thumbnails for videos that, when you click, it popups a YouTube video.
This thumbnails are simple images of 195x195 but the end client it will upload as it, and I would like to add via CSS a "play icon" over the image of the video (compatible with IE7+). I've no idea on how to handle this.
Can anyone help me?
Thank you in advance!
you might want to do something like this:
<div class="imageWrapper" style="position: relative; width: 195px; height: 195px;">
<img src="/path/to/image.jpg " alt=.. width=.. height=..style="position: relative; z-index: 1;" />
<img src="/path/to/play.jpg " alt=.. width=.. height=.. style="position: absolute;left:80px; top: 80px;z-index: 10;" />
</div>
of course do not use style="", but put styles into separate CSS files.
Explanation:
put two images into div. If you give position: relative; property to your wrapper div, then anything inside this div would be position relatively to it. It means, you can add position: absolute; to the play image and using left: XXpx; and top: XXpx; you can position it where you want. You might want to use z-index to define which picture should be on the top. The higher z-index the higher layer. Please note: z-index works only if position is set.
You can use position: relative or position: absolute to position images on top of the other.
When positioning absolute, these elements are positioned absulute within the parent element that has a relative or absolute position, so not relative to the page as is often thought.
I demonstrated this in this fiddle:
http://jsfiddle.net/W5TFS/
You can create a class that will show the image.
showPlay{
background-image:url('play.png');
z-index:1
}
Then you can use it in every image that you need to show it.
You can try it here.
I want to float a div to the right at the top of my page. It contains a 50px square image, but currently it impacts on the layout of the top 50px on the page.
Currently its:
<div style="float: right;">
...
</div>
I tried z-index as I thought that would be the answer, but I couldn't get it going.
I know it's something simple I'm missing, but I just can't seem to nail it.
What do you mean by impacts? Content will flow around a float. That's how they work.
If you want it to appear above your design, try setting:
z-index: 10;
position: absolute;
right: 0;
top: 0;
If you don't want the image to affect the layout at all (and float on top of other content) you can apply the following CSS to the image:
position:absolute;
right:0;
top:0;
If you want it to float at the right of a particular parent section, you can add position: relative to that section.
Try setting its position to absolute. That takes it out of the flow of the document.