TV-Shaped CSS Figure delimiting image - html

I can't seem to figure how to accomplish the following.
I have this shape:
This is the desired outcome:
However, when I apply the overflow to the child div this happens:
Or this when the overflow is in the parent div
I have tried splitting the CSS into more divs and then trying to overlap them and all these attempts have been failures.
The HTML and CSS are the following
CSS:
#tvshape {
position: relative;
width: 200px;
height: 150px;
margin: 20px 10px;
background: #0809fe;
border-radius: 50% / 10%;
color: white;
text-align: center;
text-indent: .1em;
}
#tvshape:before {
content: "";
position: absolute;
top: 10%;
bottom: 10%;
right: -5%;
left: -5%;
background: inherit;
border-radius: 5% / 50%;
}
#tvshape img {
height:100%;
width:100%;
}
HTML (Nothing special):
<div id="tvshape">
<img src="http://wallpaperpanda.com/wallpapers/pbc/RER/pbcRERyTy.jpg">
</div>
And Here is the JSFiddle and the CSS and HTML.
How could I accomplish so ?
Guidance will be highly appreciated.
EDIT: I required the image to be an element of it's own, background:url() it's not what I'm looking for.
EDIT #2: This was one of the solutions given, the figures are not the same ones, the rounded left and right sides dissapear.
Thank you.

I could come up with two options, though one involves leaving out the image-element, and the second uses jQuery... (I honestly don't think it's possible to do with the image-element...sorry.)
Option 1)
Since the image URL has to be in the HTML code, adjust the code like this:
<div id="tvshape" style="background-image: url(http://wallpaperpanda.com/wallpapers/pbc/RER/pbcRERyTy.jpg);"></div>
Then add the following CSS:
#tvshape {
background-position: center center;
}
Here's a fiddle: http://jsfiddle.net/Niffler/cqPR8/
Option 2)
Basically the same as Option 1, except I "cheated" by leaving the HTML code as it was, i.e.
<div id="tvshape">
<img src="http://wallpaperpanda.com/wallpapers/pbc/RER/pbcRERyTy.jpg" alt="" />
</div>
Add some jQuery so that the HTML ends up looking like Option 1:
var tvbackground = $('#tvshape img').attr('src');
$('#tvshape').css('background-image', 'url(' + tvbackground + ')');
Then finally hide the image-tag with CSS:
#tvshape img {
display: none;
}
Here's another fiddle: http://jsfiddle.net/Niffler/4WFL5/

I just included this code in your css
#tvshape{ background:url('http://1.bp.blogspot.com/_Y1fFfKjiX2g/S_gMwLeGtjI/AAAAAAAALlE/vdX0ttHeEjg/s1600/CLOUDS2.jpg')center no-repeat; }
The image used is taken randomly just for example purposes. Is this desired version you want?
JSFiddle : Link

Related

using z-index and diagonal items inside of a table <td> element

I am trying to "hide" any overflow from a diagonal line inside of a table <td> element.
example: https://jsfiddle.net/edwardsmarkf/8zuk6naL/47/
span#diagLine {
transform: rotate(345deg);
transform-origin: left bottom;
position: absolute;
...........
z-index: -100; /* does not do anything! */
overflow: hidden; /* does not do anything! */
}
In my example copied from here and here,the z-index does not seem to work for me even though the position is absolute as suggested here and here. And the overflow property does not appear to work for me either.
It behaves as if a diagonal line is special and the CSS properties no longer apply to it.
I was unable to find any SO suggestions that apply to a diagonal line inside of a table <td> element.
I could probably do something with jScript, but was hoping for a pure CSS solution, hopefully with just minimal changes. Or maybe I have missed something very obvious?
Thank you very much.
ok I figure out you can use a class (.bottom) for the "seeable" td
check this out
span#diagLine {
margin-left: 0px;
margin-top: 10px;
transform: rotate(345deg);
transform-origin: left bottom;
position: absolute;
display:relative;
text-decoration: none;
color: blue;
font-size: 13px;
z-index:-10;
}
td.styleTableTdItem {
width: 60px;
height: 60px;
z-index: 1;
}
td:not(.bottom){
background-color:white
}
https://jsfiddle.net/s23fhdbe/1/
You can add something like this if you are dealing only with the elements shown in the example
td:last-child{
background-color:white
}

How to increase clickable area of an element without increasing its padding?

I have created an unordered list and styled it accordingly using CSS in order to achieve the following Customer Testimonial Selectors:
Everything seems to be fine except one thing - when I view my webpage on mobile phone these selectors are very hard to click on (you have to click them very very precisely in order to select the second testimonial).
I've tried increasing padding on the element, however it would not work for me because increasing the padding automatically increases the size of the actual selector element... Here is my html & css:
HTML
<div class="col-xs-8 col-xs-offset-2 text-center indent-bottom">
<ul>
<li id="client-1-selector" class="client-selector active-client"></li>
<li id="client-2-selector" class="client-selector"></li>
<li id="client-3-selector" class="client-selector"></li>
<li id="client-3-selector" class="client-selector"></li>
</ul>
</div>
CSS
.client-selector {
cursor: pointer;
list-style: none;
display: inline-block;
height: 15px;
width: 15px;
background-color: #D9D9D9;
border-radius: 50%;
}
.client-selector:not(:last-child) {
margin-right: 14px;
}
.active-client {
background-color: #E48210;
}
Any suggestions? Thanks.
Try something like this:
.client-selector { position: relative; }
.client-selector::after {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}
This will put an ::after pseudo-element around your .client-selector elements that is twice the width and height.
Using pseudo elements you can do it:
Here is an article explaining about the details.
As an advice:
This technique works IE8+

creating a css triangle in percentage

I am trying to create a div that is square on the top site and flows into a triangle,
the square part is not so hard, and works fine, but the triangle part is a bit harder.
The box needs to change from size with the screen size, in the square i did this by using % in the width and height, but i cannot use the % sign in the border property
The code i have on this moment
HTML
<div id="overV12" class="menuItem" onclick="scrollToT('#overons')" onmouseover="setHover('overV12')" onmouseout="setOldClass('overV12')"><div class="menuInner">Over V12</div></div>
CSS
div.menuItem
{
height: 5.38%;
width: 7.44%;
position: fixed;
background-color: rgb(239, 239, 239);
cursor: pointer;
z-index: 12;
text-align: center;
top: 4.3%;
}
div.menuItemHover
{
height: 5.38%;
width: 7.44%;
position: fixed;
cursor: pointer;
z-index: 12;
text-align: center;
top: 4.3%;
background-color: rgb(211, 211, 211);
}
div.menuItemActive
{
height: 7.8%;
width: 7.44%;
position: fixed;
cursor: pointer;
z-index: 12;
text-align: center;
top: 4.3%;
background-color: Black;
color: White;
}
The JavaScript is used for setting the class: i did this because i use a parralax library and wanted to set the button on "active" on a certain height
i hope someone can help me (and perhaps others) with this problem
jsfiddle
example
My idea is that when the div is set on class menuItemActive, it will have the arrow, else not
This is only when it is set on active
This uses two overlapping divs to create the triangle and this method to make things fluid while maintaining the aspect ratio.
Working Example
.div1 {
width:100%;
height:100%;
border: 1px solid red;
position:absolute;
z-index:2;
}
.div2 {
width:70%;
min-height:70%;
transform:rotate(45deg);
border:1px solid blue;
position:absolute;
left:15%;
top:65%;
z-index:1;
}
#container {
display: inline-block;
position: relative;
width: 25%;
}
#dummy {
padding-top: 100%;
}
#element {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
I left it without a background so you could see how it works.
You can do triangles in CSS.
Here's a link to an article, outlining the general technique: http://css-tricks.com/snippets/css/css-triangle/. There's also a variety of similar/other approaches for slightly different situations I've found and used, just search "css triangles".
To briefly describe the technique: it uses four borders on an element (if you wanted a down arrow, you'd put this element inside your <div id="overV12">, or depending on the effect, apply it to your inner <div>). Some are transparent, some aren't. By changing the border widths and colors, you can generate CSS triangles, which can be fully customized to form different angle degrees, lengths, etc. I've also seen this concept used to create CSS-only speech bubbles as well as tooltip handles.
I've used this technique extensively, and in my use cases, it worked in every browser (although I do remember having a problem with IE6 on one project).
I found the solution by using javascript instead of percentage,
Fiddle
I hope this can help some other people as well
The java script i used is this:
$(document).ready(setSize());
function setSize() {
var halfWidth = ($('.div1').width()) / 2;
$('.div2').css('border-width', ('50px ' + halfWidth + 'px 0 ' + halfWidth + 'px'));
$('.div2').css('top', ($('.div1').height()));
}
its better to use a background image for custom shaped like this
it'll make it easier to manager and you can make it adjust itself for different resolutions easily

Half my CSS Sprite images not displaying

I have a table of roll over images / links, for which I was hoping to use a sprite for but for some reason when the code goes live only around half of the images display.
My code is here if anyone wants to look at it in the wild:
http://www.geckosourcing.co.uk/ebay/Promotions/Cross_Promotion.html
http://www.geckosourcing.co.uk/ebay/Promotions/Cross_Promotion.css
HTML:
<td height="88" width="88"><a class="1000AQwpanel" href="http://goo.gl/mOu8L">1000 Wetroom Panel</a></td>
CSS:
.1000AQwpanel {
display: block;
width: 88px;
height: 88px;
background: url('http://www.geckosourcing.co.uk/ebay/Promotions/Promotion_Sprite.jpg') -704px 880px;
text-indent: -99999px;
}
.1000AQwpanel:hover {
background-position: -704px 792px;
}
The think that has been getting me as this code looks the same as the sections that work. If anyone can show where I am going wrong it would save me pulling my hair out.
Thanks
I suspect this is due to class names that start with a number:
class="760Corner"
Valid class names must begin with a letter, underscore or hyphen.
class / id names may not start with a number. Html wil valid the code, it's the css that gives the problem.
You can use a different style of css to go around this.
css
a[class="760corner"]{
}
PS.
Why do you have the text inside your image? Try putting text in a span like this
HTML
<a class="corner-760">
<span>Your text</span>
</a>
css
a {
display: block;
position: relative;
background: url('../images/.....jpg');
width: 80px;
height: 80px;
}
a > span {
display: block;
text-align: center;
height: 100%;
}
a:hover > span {
display: none;
}
a.corner-760 {
background-position: ........;
}

Clickable image with sprites

So I've got a series of clickable images in my page. I've tried to optimise this by generating a single image containing all the images I need and I intend to use sprites to select the one I want. I'm having trouble figuring out the best way to add anchor tags to the sprites though?
So I'm after a clickable HTML element that supports sprites, preferably without using JavaScript. I can do it using JavaScript but I'd prefer to avoid it.
OK, here's my code, what there is:
.touringEscorted {
height:125px;
width: 214px;
background-image: url('/Images/Travel2New/ToursImages/ToursBanners.jpg');
background-position: 0 0;
}
.touringNew {
height:125px;
width: 214px;
background-image: url('/Images/Travel2New/ToursImages/ToursBanners.jpg');
background-position: -10px 0;
}
I've tried
<div class="touringEscorted">
and
and several others. Seems there's no way to use sprites/background images and anchor tags at the same time. Am I right?
Any suggestions?
Ok then :
Should work, but adding display:block; to the CSS :
.touringEscorted {
height:125px;
width: 214px;
background-image: url('/Images/Travel2New/ToursImages/ToursBanners.jpg');
background-position: 0 0;
display:block;
}
Like this?
<a class="sprite sprite1" href="javascript:;">Link Text</a>
sprite {
display: block;
background: url(path/to/image/file.ext);
text-indent: -9999px;
}
sprite1 {
width: WWpx;
height: HHpx;
background-position: -NNpx - MMpx;
}
Doesn't Google consider off screen text as spammy? I came up with a modification. I put the link in another element, in this case a table. I added the background image class in the element and in the link like this:
CSS code:
.sprite{
background: url('images/sprite.png') no-repeat top left;
}
.sprite.termite {
background-position: 0px -499px;
width: 150px; height: 113px;
display: block;
}
HTML code:
<td class="td sprite termite">
</td>
It renders the image in the table perfectly and clicks!