I created the button on the left purely with CSS. It is a div within a div. However, the three buttons on the right are background properties on img tags. I did this so I could simulate a rollover effect following instructions from here.
Now, is there a way to add the inner border, as in the first button, to the other three using CSS?
Fiddle here.
According to the box model, padding is between the content and border. You should be able to style the images like:
.img-btn {
background: #FFF; // inner border color
padding: 2px; // inner border width
border: 2px solid #[yourgreen]; // outer border
}
You shouldn't need any extra divs to accomplish this, even for your pure CSS button. Following style is for the case when the image is a background-image:
.img-btn {
background: #FFF url('your.img') no-repeat;
padding: 2px;
border: 2px solid #[yourgreen];
width: [image width];
height: [image height];
background-position: center center;
}
Here's a DEMO of double-border as described above.
You don't need two <divs> and an <a> to do the button. You can do it with a single <a>. For both the images and the button you can use box-shadow to do the outer border. Center the background-images in the <img> elements.
Demo: http://jsfiddle.net/ThinkingStiff/bNmzB/
Output:
HTML:
<a id="add" href="#">Add To Cart</a>
<img id="facebook" class="icon" />
<img id="twitter" class="icon" />
<img id="email" class="icon" />
CSS:
#add {
background-color: #9bc9c7;
border: 1px solid white;
box-shadow: 0 0 0 2px #9bc9c7;
color: white;
display: inline-block;
font: normal 13px/25px Helvetica, Arial, Sans Serif;
height: 25px;
margin-right: 6px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
width: 120px;
vertical-align: top;
}
#add:hover {
background-color: #eabeb2;
box-shadow: 0 0 0 2px #eabeb2;
}
.icon {
background-color: rgb( 155, 201, 199 );
border: 1px solid white;
box-shadow: 0 0 0 2px rgb( 155, 201, 199 );
height: 25px;
margin-right: 3px;
width: 25px;
}
Use the same approach as you did for the button - just treat the icons as background images to the inner div. So you should have a div with some padding, an inner div(in your case img) with a white border, and a background image (the icons.)
Assuming you can't modify the icon images directly, just wrap them in a div in the same way as "Add to Cart". You'll also need to use either
background-position: center center;
to ensure that the icon stays centered within the smaller img, and/or
background-size: 24px 24px;
to scale the background down a bit so the white border doesn't run into the symbols.
Related
I'm trying to create a World Cup 2018 page using the design that was used in the world cup 2018 qualification european zone (using the image that i've attached).
Please correct me if i'm wrong for some of these points:
In the EUROPEAN ZONE title, i can achieve this with a trapezoid rounded border.
For the title banner, it is using an uneven border div. This will have the same div alongside with the country names. I've tried using border-radius with the / operator maybe there is a better solution (if there is).
And also if you can see there is a small lens flare (not sure if that is the correct term) on top of the div.
For all the banner div i can put some gradient background color to make it look it has a 3D effect and add some glossy effect.
For the dark transparent background i can do it the same with border-radius. maybe with some concave border using the :after selector.
This part is where i'm stuck: I'm not sure how to recreate the country flags that has a convex shape but it looks like wrapping the div (maybe add a box-shadow effect) and add a glossy effect.
I'm assuming I can achieve this with CSS only, or maybe a little bit of Javascript. But no jQuery because I'm planning to create this in react.
Here's what I've got so far:
body {
background: white;
}
#wrapper {
border: 1px solid black;
border-radius: 20px 20px 40px 40px / 40px 40px 90px 90px;
display: flex;
height: 40px;
align-items: center;
}
#flag {
width: 70px;
height: 100%;
background: red;
border-radius: 20px 20px 40px 40px / 40px 40px 90px 90px;
margin: 0 20px;
}
#flag:after {
content: '';
background: white;
position: relative;
height: 100%;
width: 30px;
display: block;
left: 44px;
border-radius: 20px 20px 40px 40px / 40px 40px 90px 90px;
}
<div id="wrapper">
<div id="flag"></div>
<div id="team">Country Name</div>
</div>
View on JSFiddle
I have a textarea for comments and a button to show or hide it (toggle). If I want to hide it by default (display: none) when I click the button to show it, the style is broken but if it's not hidden (display: block) I can click without problems, the style will be fine.
html:
<a id="1" class="comment_button a_button" title="Dejar un comentario">Comentar</a>
<div id="hide_1" class="rows" style="display: none;">
<ul id="UL_101">
<!-- New comment row -->
<li class="newComment_row">
<div class="userComments_photo">
<img class="photo" src="/images/profile/' . $_SESSION['photo'] .'" alt="" />
</div>
<textarea id="' . $imgID . '" class="textarea" rows="1" placeholder="Escribe un comentario..." title="Escribe un comentario..."></textarea>
</li>
</ul>
</div>
css:
.rows {
height: auto;
width: 494px;
background: rgb(246, 247, 248) none repeat scroll 0% 0% / auto padding-box border-box;
border-radius: 0 0 3px 3px;
margin: 8px -12px -12px;
}
#UL_101 {
width: 494px;
list-style: none outside none;
margin: 0px;
padding: 0px;
border-top: 1px solid rgb(225, 226, 227);
}
/* li */
.newComment_row {
height: auto;
position: relative;
width: 470px;
background: rgb(246, 247, 248) none repeat scroll 0% 0% / auto padding-box border-box;
border-radius: 0 0 2px 2px;
list-style: none outside none;
margin: 0px 12px;
padding: 4px 0px 8px 0px;
}
.textarea {
resize: none;
width: 416px;
font: normal normal normal 12px/15.3599996566772px Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif;
position: initial;
padding: 8px 3px 0 3px;
margin: 0 7px;
overflow: hidden;
}
and jquery:
// show rows
$('.comment_button').on('click', function () {
$('#hide_' + this.id).slideToggle('fast');
});
function h(e) {
$(e).css({
'height': 'auto',
'overflow-y': 'hidden'
}).height(e.scrollHeight);
}
$('textarea').each(function () {
h(this);
}).on('input', function () {
h(this);
});
display: none breaks the style: http://jsfiddle.net/cb41hmpo/
display: block does not break it: http://jsfiddle.net/cb41hmpo/1/
It seems the problem is the auto-height function... Is there a way to fix this?
I'd like to keep that textarea size if possible, whatever the changes are.
It's not a big deal but if display is set to block and I click the button, the textarea placeholder text appears some fuzzy or blurred for a second, is that a normal thing or can it be fixed?
If we go through your code
function h(e) {
alert(e.scrollHeight);
$(e).css({
'height': 'auto',
'overflow-y': 'hidden'
}).**height(e.scrollHeight)**;
}
If you look at the bold section here you are assigning the scrollHeight to $e. If we do an alert we can see that the height of textarea when the parent div is hidden is 0 and it is 23 when the div is shown it is 23 px. Now in the (star marked -->height(e.scrollHeight) text we are assigning explicitly that height to the textarea (bold text). Hence, it is smaller in size. Hence your height auto is not coming into picture as you are assigning height by e.scrollHeight.
Try removing the bold text from both the snippets. The result you will get will be the same.
Hope this be of some help.
Happy Learning :)
So I am trying to add a custom style to the select2 jquery plug, it is a tag like multi selector plugin. The way that select2 renders selected "tags" guides my css rules to try and style. select2 renders a <div> containing the selected tag text followed by an <a> to remove that selected tag if the user desires.
I want the close btn and the tag text to look like one block. I have it almost where I want but you can see that the <a> element and the div element vary in height by a pixel or two. I thought maybe this was a display:inline versus display:block issue but I have tried setting both the elements to display:inline-block with no luck, here is a jsfiddle, just select both option1 and option2 to see my issue:
http://jsfiddle.net/QRNqm/
And here is my code, remember I am using the select2 plugin also:
$(function(){
$('#mdlTags').select2();
});
.select2-search-choice-close {
padding: 2px 14px 3px 0;
border-radius: 2px 2px 2px 2px;
background: url(/images/projects/closeWhite.png) no-repeat 5px center #bdc6e5;
}
.select2-choices li div {
border-radius: 2px 2px 2px 2px;
color: #fff !important;
text-decoration: none;
padding: 3px 14px 3px 12px;
background-color: #bdc6e5;
}
<select multiple="multiple" id="mdlTags" class="skipMsDropdown" style="width:330px;">
<option value="1" >Option 1</option>
<option value="2" >Option 2</option>
</select>
Replace .select2-search-choice-close class with below:
.select2-search-choice-close {
padding: 2px 14px 3px 0;
border-radius: 2px 2px 2px 2px;
background: url(/images/projects/closeWhite.png) no-repeat 5px center #bdc6e5;
height: 14px; /* given height (actual 13px and 1px to adjust bottom margins) to adjust line-height of parent element */
margin-top: -1px; /* to adjust top margins to get in proper line */
}
Here is a working DEMO.
It's now on the same level. Here is the edited css.
.select2-search-choice-close {
background: url("/images/projects/closeWhite.png") no-repeat scroll 5px center #BDC6E5;
border-radius: 2px;
padding: 3px 14px 3px 0; // increase the top padding for 1 point.
}
.select2-search-choice-close {
background: url("select2.png") no-repeat scroll right top rgba(0, 0, 0, 0);
display: block;
font-size: 1px;
height: 13px;
outline: medium none;
position: absolute;
right: 3px; // Reduce the top position for 1 point
top: 3px;
width: 12px;
}
First off, you have one less pixel of top padding on the select2-search-choice-close style. But even once you fix that, there will still be a pixel of difference between the two elements.
If you take a look at the demo on the Select2 page, that's the way it appears there as well (with one vertical pixel difference between the two elements). The difference is that they are applying the unifying style on the container that holds these two elements, rather than styling each of these elements separately.
If you make these two changes, you end up with something like this:
http://jsfiddle.net/Cv6cH/
Please take a look at this link. Hover cursor on any movie thumbnail. Have you noticed that, all li elements moving down? How can I fix that problem?
Also, click on any thumbnail, player div will slide down. there is no box shadow under #player_container even if I set it in css files
#player_container{
display:none;
height:510px;
width: 100%;
background-image: url(images/bg/bg_tile.jpg);
margin-top: -510px;
padding-top: 20px;
-moz-box-shadow: 0px 10px 5px #888;
-webkit-box-shadow: 0px 10px 5px #888;
box-shadow: 0px 10px 5px #888;
}
On video add a transparent border seems to fix it
.video {
border: 1px solid transparent;
float: left;
font-size: 11px;
height: 150px;
margin: 0 25px 25px 0;
width: 228px;
}
There is a couple off different way to fix the next part off your question. One quick way is too add another container like
<div style="display: block;" class="gradient sh" id="player_container">
<div class="jquery-youtube-tubeplayer" id="player">
<div id="tubeplayer-player-container1324082555277"><iframe width="853" height="480" frameborder="0" src="http://www.youtube.com/embed/LxBGDijiii0?autoplay=1&autohide=1&controls=1&rel=0&fs=1&wmode=transparent&showinfo=0&modestbranding=0&start=0&theme=dark&color=red&enablejsapi=1&origin=http://tural.us" title="YouTube video player" allowfullscreen=""></iframe></div></div>.
<div class="bottomSpan"></div>
</div>
and put your box shadow on this
.bottomSpan {
box-shadow: 0 10px 5px #888888;
display: block;
height: 17px;
position: absolute;
width: 100%;
}
For me changing the margin on the corresponding < li > would make more sense.
That is because on hover you are adding a border which makes the container 2px bigger
the solution to give the initial class a border
.video {
border: 1px solid #fff
float: left;
font-size: 11px;
height: 150px;
margin: 0 25px 25px 0;
width: 228px;
}
Second Problem:
To make z-index work you need to give it a position:relative property
#player_container {
display: none;
height: 510px;
width: 100%;
background-image: url(images/bg/bg_tile.jpg);
padding-top: 20px;
-moz-box-shadow: 0px 10px 5px #888;
-webkit-box-shadow: 0px 10px 5px #888;
box-shadow: 0px 10px 5px #888;
z-index: 2;
position: relative;
}
You're adding a border when the mouse hovers but not reducing the size of the element. The "height" and "width" of an element, in the W3C box model, describe the size of the contents of a block element. The padding and the border are added to that.
Some browsers allow you to switch back to the "border-box" box sizing model:
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
However Internet Explorer wont, I don't think, understand that. Maybe IE9 or 10 would understand:
-ms-box-sizing: border-box;
(You'd put that on the ".video" style.)
edit — as to the problem with the shadow on the player: there's no shadow because there's no room for a shadow. If you make the player box "position: absolute", and correspondingly adjust the content somehow (maybe give the "wrapper" div a big top padding the same as the player size) then you'll see a shadow.
You really should be using something like Firebug to play with the CSS interactively.
I'm afraid your mixing things up a bit:
Your background-image is set on #player-container - if you want #player-container to have a shadow, you'll need an extra containing div for this background. Right now #player-containerdoes have shadow, but since it's 100% wide, and fills the vertical space, the shadow doesn't show.
Your player is exactly 853px x 480px, so you'll have to set #player-container to exactly these dimensions (no padding, no margin, they will be added to the width/height)
Add padding to the extra containing div, which also holds the background.
also (but not so important): #player-container has width:100% - that makes no sense - default is width:auto, so #player-container will automatically take 100% width
Hello I am using this plugin: http://www.wbotelhos.com/capty/
The problem I am having is that the image I am putting this on already had a shadow on rollover with some simple css:
a:hover img.imagedropshadow {
-moz-box-shadow: 1px 1px 5px #999;
-webkit-box-shadow: 1px 1px 5px #999;
box-shadow: 1px 1px 5px #999;
}
a:active img.imagedropshadow {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
After adding the jquery caption, I have the caption popping up but the image no longer has the shadow on roll over as I believe the image is not really being rolled over because of the jquery created div surrounding the image.
The image html is just like this:
<a href="blah.html ">
<img class="default imagedropshadow" border="0" width="290" height="400" title=" test" alt=test2" src="images/1797sbgx.jpg">
</a>
The caption css is:
div.capty-caption {
background-color: #ccc;
color: 000;
font: bold 11px verdana;
padding-left: 10px;
padding-top: 7px;
font-family: 'Quicksand', sans-serif;
text-transform:uppercase;
font-size: 87%;
font-weight: 700;
}
div.capty-caption a {
color: #318DAD;
font: bold 11px verdana;
text-decoration: none;
text-shadow: none;
}
and the javascript for the capty plugin is: http://pastebin.com/xc1h1Mna
Any help is appreciated
Change the z-index of the image. The image will now always be at the top of the caption.
The CSS
.default.imagedropshadow {
z-index: 1000;
}
Ok so here is what I did to fix it.. but it ruins reusability:
on line 51
$wrapper.css({
height: '410',
overflow: 'hidden',
position: 'relative',
width: '295'
});
hard coded height and width to accomodate larger image size due to shadow. This means it is only good for this image. I can I guess use the original This.height + 10 or whatever but not all images might have shadows.. In any case I am only using it on 1 size image so for my needs this will be good enough for now..
on line 91:
$caption.animate({ top: (-90) }, { duration: options.speed, queue: false });
changed to -90 so it does not overlap the shadow