I have two problems with my portfolio section which is not as smooth as I want it to be. Here they are:
I wanted my projects to change background-color and show a small plus sign when hovering over them. In the same time I wanted to add a "transition: all 0.5s ease-in-out;" but the result is not what I expected. It probbaly happens because my "plus sign" should be located in another div but I didn't know how to make it work. Instead I put it here:
.projectshot a .over:hover{
position: absolute;
background: url(http://www.iconsea.com/uploadimage/smallsort/4015/4dxtdhpaxqw.png) center center no-repeat rgba(51, 51, 51, 0.6);
border-radius: 8px;
height: 150px;
width: 200px;
margin: 10px;
}
This is the effect I wanted to achieve: http://bjorsberg.se/
The second problem that bothers me is that, if you look really carefully, when you approach each of the projects with the mouse the mouse pointer starts to "dance" and it behaves crazy??? How can I fix that???
Here is my JSFiddle:
http://jsfiddle.net/8fCMA/2/
.plus{
width: 100px;
height: 100px;
position: absolute;
left: 50%;
top: 50%;
margin: -49px 0 0 -56px;
background: url(img/plus.png) center center no-repeat;
}
I am quite new to web design (4 months since I started learning) and I am clearly not good with positioning div's inside div inside another div... So, please feel free to correct my fiddle if you see any trouble I created. Thanks!
I would simplify the html structure if I were you, as it is not necessary.
e.g.: projectshot can look like this:
<div class="projectshot">
<a href="http://www.yahoo.com" target="_blank">
<img alt="Sushi" src="...">
</a>
</div>
and you can add the "cover" as :before pseudoelement.
Then - in css all you need to do is to add this to the "cover" element:
opacity: 0;
transition: opacity .2s;
and - on hover - change the opacity to 1:
opacity: 1;
here's the updated demo
(I've removed a lot of your html/css code just for demo purposes)
I've just made some small changes including:
Moving the hover to the .projectshot box.
Moving background-position and background-repeat to the non
hover definition.
Adding the transitions.
It works for now but you can still remove a lot of code. Even the html can be heavily reduced.
I suggest you to have a look at that too (DEMO).
.projectshot{
position: relative;
padding: 10px;
height: 150px;
margin-bottom: 30px;
display: inline-block;
}
.projectshot img{
height: 150px;
width: 200px;
border-radius: 8px;
-webkit-box-shadow: 0 9px 13px rgba(0,0,0,.14);
-moz-box-shadow: 0 9px 13px rgba(0,0,0,.14);
box-shadow: 0 9px 13px rgba(0,0,0,.14);
}
.projectshot:hover .over{
background-image: url(http://www.iconsea.com/uploadimage/smallsort/4015/4dxtdhpaxqw.png);
background-color: rgba(51, 51, 51, 0.6);
transition: all 0.5s ease-in-out;
}
.projectshot:hover {
cursor: pointer;
}
.over{
position: absolute;
border-radius: 8px;
height: 150px;
width: 200px;
box-sizing:border-box;
-moz-box-sizing:border-box;
background-repeat: no-repeat;
background-position: center center;
transition: all 0.5s ease-in-out;
}
.inner{
background: rgba(113,122,137,.85);
border-radius: 8px;
width: 100%;
height: 100%;
display: none;
}
.plus{
width: 100px;
height: 100px;
position: absolute;
left: 50%;
top: 50%;
margin: -49px 0 0 -56px;
background: url(img/plus.png) center center no-repeat;
}
Related
I'm trying to put an image inside a button like this: example
The code I have so far is:
<button class="buttoni" style="width: 270px; height: 46.9px;">Earn Money Helping <b>People</b> <div><img src="img/pla.png" style="width: 25px; height: 25.7px; margin-left: 220px; margin-top: -50px;"> </div></button>
You could create the icon using CSS instead. This would allow you to apply transitions / animations etc.
.buttoni {
width: 270px;
height: 46.9px;
position: relative;
transition: .2s ease-in-out;
cursor: pointer;
border: 0;
}
.buttoni:before,
.buttoni:after {
position: absolute;
content: '';
transition: .2s ease-in-out;
}
.buttoni:before {
background: #29d4a2;
border-radius: 50%;
width: 25px;
height: 25px;
right: 15px;
top: 10px;
}
.buttoni:after {
width: 0;
height: 0;
display: block;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 6px solid #FFF;
transform: rotate(-90deg);
right: 20px;
top: 19px;
}
.buttoni:hover {
background: #29d4a2;
}
.buttoni:hover:before {
background: blue;
}
<button class="buttoni">Earn Money Helping <b>People</b>
</button>
You can try this:
<button class="buttoni" style="width: 270px; height: 46.9px;">Earn Money Helping <b>People</b><img src="img/pla.png" style="position: relative; float: right; width: 25px;"></button>
Adjust the height as needed for the image.
Are you just trying to learn HTML/CSS, I'd suggest putting the styling into a stylesheet rather than inline.
Well, if you want to do it using html
<button class="buttoni" style="width: 270px; height: 46.9px;">Earn Money Helping <b>People</b><img src="img/pla.png" style="width: 25px; height: 25.7px; margin-left: 220px; margin-top: -50px;"></button>
Do not call div inside button because it is an erroneous form, since the button supports the insertion of images by default
In case you want to do it using CSS
This should do do what you want, assuming your button image is 16 by 16 pixels.
.buttoni {
background-image: url(/images/buttons/add.png); /* 16px x 16px */
background-color: transparent; /* make the button transparent */
background-repeat: no-repeat; /* make the background image appear only once */
background-position: 0px 0px; /* equivalent to 'top left' */
border: none; /* assuming we don't want any borders */
cursor: pointer; /* make the cursor like hovering over an <a> element */
height: 16px; /* make this the size of your image */
padding-left: 16px; /* make text start to the right of the image */
vertical-align: middle; /* align the text vertically centered */
}
how to avoid slide transition in social icons on hover?
i want my all social icons in one png file and use transition also but it show up with sliding it not transition like two different images
#social_icons {
display:inline-block;
background: url(http://www.gobothell.com/wp-content/uploads/2012/01/FB-and-Twitter-icons-300x181.jpg) no-repeat center center;
background-position: 0px 0px;
width: 150px;
height: 175px;
transition: 0.5s ease, forward;
border: 1.5px solid blue;
margin:10px;
}
#social_icons:hover {
background: url(http://www.gobothell.com/wp-content/uploads/2012/01/FB-and-Twitter-icons-300x181.jpg) no-repeat center center;
background-position: -150px 0px;
width: 150px;
height: 175px;
}
#social_icons2 {
display:inline-block;
background: url(http://www.florestrekkingtour.com/userfiles/images/FB_icons.png) no-repeat center center;
width: 200px;
height: 200px;
transition: 0.5s ease, forward;
border: 1.5px solid blue;
margin:10px;
}
#social_icons2:hover {
background: url(https://cdn3.iconfinder.com/data/icons/inside/PNG/256x256/icontexto-inside-facebook.png) no-repeat center center;
background-position: 0px 0px;
background-size: 200px 200px;
width: 200px;
height: 200px;
}
h2 {
background:rgba(0, 0, 0, 0.7);
color:yellow;
text-align:center;
text-shadow:0px 0px 10px lime;
margin-top:45%;
}
1 image
<div id="social_icons"><h2>Hover me</h2></div>
2 images
<div id="social_icons2"><h2>Hover me</h2></div>
This is not possible with CSS3 Transitions with a single element, the property your transitioning(changing) is background-position, hence the reason it appear sliding,
If a Fade In/Fade Out effect is what you require, you could use a CSS3 Animation to fade the element out on hover, move it to the desired background position then fade back in the new image.
If a Cross-fade is what you require there is either background-image: cross-fade()
background-image: cross-fade(url("logo-box.png"), url("logo-bare.png"), 50%);
But it has very limited browser support i.e. http://caniuse.com/#feat=css-cross-fade.
Or probably the best option is using 2 elements and fade out one on top of the other, you could use a Pseudo Element (IE8+) to fake an extra element i.e.
#social_icons:before {
content:"";
display:inline-block;
position:absolute;
opacity:0;
background: url(https://cdn3.iconfinder.com/data/icons/inside/PNG/256x256/icontexto-inside- facebook.png) no-repeat center center;
background-position: 0px 0px;
background-size: 200px 200px;
width: 200px;
height: 200px;
}
See http://jsfiddle.net/sjmcpherso/kr7ec28q/ for working example
I am creating a web app that uses CSS' transform scale property. As shown by the image below, I have an object inside of a container, which fits nice and snugly inside, without any overflowing content. This is how I wish for it to be.
My issue is brought up when I re-scale the object to a size greater than the container. As shown by the image, clearly the object is larger than the container. As marked by the arrows and labels of "scrollable area", the container can scroll to these areas, but the parts labelled with "hidden" are not visible or accessible through the scroll due to their overflow.
For a practical view of my issue, here's a link to a codepen with my code:
CodePen
Snippets of my CSS code area as follows:
#container {
position: fixed;
width: 300px;
height: 200px;
border: 1px solid #000000;
left: 0px;
top: 0px;
margin-left: 330px;
margin-top: 10px;
overflow: scroll;
display: block;
text-align: center;
}
#object {
position: relative;
width: 120px;
height: 120px;
display: inline-block;
background-color: rgba(255, 0, 255, 0.45);
margin-top: 40px;
border-radius: 25px;
transform: scale(3); /* This would be scale(1) on the small object */
}
This issue is holding back the development of my web app, so thanks in advance for your time and contributions.
My best guess would be that this is happening because of transform origin. Try setting it to 0 0 should fix Your issue:
#object2 {
position: relative;
width: 120px;
height: 120px;
display: block;
background-color: rgba(255, 0, 255, 0.45);
border-radius: 25px;
transform: scale(3);
transform-origin: 0 0;
}
Demo codepen
I'm trying to make the sidebar for my theme match the main content, in that there's a solid background with a transparent border. I can make them work individually, but when I try to do both it doesn't work right. Here's the snipet of code that's been causing the problem:
#sidebar {
width: 300px;
background-color: #A3A3CC;
/*border-style: solid; border-width: 15px; border-color: rgba(255, 255, 255, 0.4);*/
position: fixed;
left: 60px;
top: 90px;
height: 490px;
margin-left: 30px;
}
I am aware that the border code is noted out, and that's because the border code and the background color code work fine individually, but when I have both at the same time, I get this.
Does anyone know how I can fix this? I just want to have a semi-transparent background under a solid one to make a nice border effect.
You can use a box-shadow instead of a border.
JSfiddle Demo
CSS
#sidebar {
width: 300px;
background-color: #A3A3CC;
box-shadow: 0 0 0 15px rgba(255, 255, 255, 0.4);
position: fixed;
left: 60px;
top: 90px;
height: 490px;
margin-left: 30px;
}
Since the border is rendered on top of the background of the div, they are stacking and not giving you what you want. You could wrap another div around it, and use that as your border:
JSFiddle
HTML
<div id="outer"><div id="sidebar"> </div></div>
CSS
#sidebar {
background-color: #A3A3CC;
width: 300px;
height: 490px;
}
#outer{
padding:15px;
background: rgba(255, 255, 255, 0.4);
position: fixed;
left: 60px;
top: 90px;
}
So I'm trying to make an image and it's background fade in when you click it using the :target selector. (Similar to Lightbox: http://lokeshdhakar.com/projects/lightbox2/, but css only).
html:
<img src="img/thumb-3.jpg">
<img src="img/thumb-4.jpg">
<img src="img/image-3.jpg">
<img src="img/image-4.jpg">
css:
.lightbox {
display: none;
position: fixed;
top: 0;
left: 0;
z-index: 2;
width: 100%;
height: 100%;
text-align: center;
background: rgba(38, 38, 38, 0);
transition: background 0.3s ease;
}
.lightbox img {
max-height: 90%;
max-width: 70%;
margin: 3%;
border-radius: 5px;
border: 5px solid #cbcbcb;
}
.lightbox:target {
display: block;
background: rgba(38, 38, 38, 0.7);
}
Only problem: it doesn't work. It tried it with other elements and it worked just fine. Any suggestions? Thanks.
Your code works in some way, but not completed. I have improved it based on your code and here's a working cross browser and responsive DEMO
Still using your :target selector.