Triangle entities like ▶ cannot display properly in Safari - html

I meant to use triangle entities ▶ and ◀ in my website as indicating arrows. It appears normal on Chrome OSX in simulation mode.
Desktop:
But it doesn't display properly at mobile end.
Mobile:
Is this some sort of default setting? How can I modify?

if you are using HTML Code or Unicode Hexadecimal arrows,
different browsers interpret differently that kind of code and they have different default settings, so probably the best way to get it working could be to use an image instead.

I always use CSS to create solid color triangles when needed:
div.triangle {
position: relative;
}
div.triangle::after {
content: "";
width: 0;
height: 0;
border-width: 10px;
border-color: transparent red transparent transparent;
border-style: solid;
left: 0;
top: 0;
position: absolute;
}
<div>
<div class="triangle"></div>
</div>
Just use more CSS to place the triangle div as per your requirements.

Related

How to fix difference display of pseudo element between Macbook and Windows Desktop?

How do you do?
I have converted XD file to html, css code.
I checked on my PC(windows), but I didn't check on Macbook.
Details:
I coded button and used pseudo element to display right arrow at the right side.
Here is my code.
HTML
<button class="register btn-top-register">Register</button>
CSS
.register{
background-color: #FF6D1F;
border-radius: 10px;
color: white;
padding: 20px 50px;
margin-right: 5%;
border: none;
position: relative;
box-shadow: 1px 5px 0px #8b3507;
}
.register::after{
content: '\1F892';
width: 20px;
height: 20px;
position: absolute;
right: 0;
}
This register button displayed triangle on Windows, but step shape on Macbook.
I tried many times to fix difference.
Could you help me how to fix and display the same shape-triangle?
You can use browserstack to test your code in different devices such as mac and ios
Have a look at these unicodes https://www.toptal.com/designers/htmlarrows/.
If you want to use of unicode I don't know exactly.
I suggest you to use SVG or img to display an icon on your button.
You can download an SVG icon from flatiIcon, or you can use of featherIcon or font awesome for example.

Change brightness of background-image?

I am wondering if it is possible to change the brightness of:
body{
background-image:url();
}
Using HTML/CSS. The reason I would like to change it, is because I just spent a rather long time making the image, but when I put it on website, it is suddenly about twice as bright. I have compared the original file and the file that is input into the website and they are both very much different colours of blue.
Is there any reason for this, and is there a way I can change the brightness?
Thanks.
You can have more layers in the "background" like this:
.someObj{
background: linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.5)),
url(myBgImage.png);
}
This will put 50% white over the original image making it brighter.
Linear-gradient function has to be used, otherwise it doesn't work.
Alternatively use:
.someObj:after{ content:''; background:rgba(255,255,255,.5); ... }
and this is better for code maintainability.
This would be an option, but it's not very practical and wouldn't work in older browsers:
body:after {
content: "";
position: fixed;
top: 0; bottom: 0; left: 0; right: 0;
background: rgba(0,0,0,0.1);
pointer-events: none;
}
Or for even better color control, try hsla() colors:
body:after {
content: "";
position: fixed;
top: 0; bottom: 0; left: 0; right: 0;
background: hsla(180,0%,50%,0.25);
pointer-events: none;
}
Really, it's better to play with the image in a image editor until you get the browser result you want.
There is no way to do this that works in every browser, but if you want, you can do it in webkit browsers (Chrome, Safari, Opera), by using the filter style:
img.lessBright {
-webkit-filter: brightness(0.8);
filter: brightness(0.8);
}
That results in the brightness being reduced to 80% in webkit browsers. I do recommend just saving another version of your image if you want to do this though.
Create a child div for the background image of the same dimensions.
Set the child divs background colour with RGBA, which includes an alpha channel (opacity).
Set the opacity accordingly between 0 and 1. 1 = Opaque, 0=Transparent, 0.5 =Translucent
HTML:
<div id="primary_feature">
<div class="feature"></div>
</div>
CSS:
#primary_feature{
background-image: url("../assets/images/misc/laptop.png");
}
.feature{
background:rgba(0,0,0,0.6);
}
An update to the other answer.
You can also use the Backdrop Filter for a much better effect. It can use any filter, in this case, the brightness filter.
This means your background will not be washed-out with a colour over the top, rather it will affect the background directly for a sharper more natural look while retaining all detail.
The downside, it isn't currently supported in Firefox, unless experimental settings are turned on. But that should change soon and as of writing this, Firefox is only 6.5% of the market.
however, it is fully supported in Chrome
body {
content: "";
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
backdrop-filter: brightness(120%);
pointer-events: none;
}
I placed a black canvas over the image and changed the brightness:
c = document.getElementById("myCanvas");
ctx = c.getContext("2d");
ctx.beginPath();
ctx.rect(0,0,c.width,c.height); //as image size
ctx.fillStyle = "#000000" + brightness;
ctx.fill();
I had the same problem, but it was with a Gif.
My workaround:
I made a very small black square image in PowerPoint and set its transparency to 50% and saved it as a file called "dimmerswitch.png"
Than I referenced that one first in the code:
body {
background-image:url("dimmerswitch.png"), url("YourImage.png");
}
You just do Photoshop to reduce the brightness if there's no other way.

Chrome: CSS Style is applied only when you go to Google Developer tools

I was trying to apply rounded corners to an OpenLayers Maps, and found that it works in Firefox, but not in Chrome. I found a related question Openlayer map with rounded corners which linked me to another question CSS Border radius not trimming image on Webkit, which explained that Google Chrome does not apply the rounded corners to grandchildren Images.
However, while testing if I could apply it directly to the children, I found a strange behavior.
If I open up chrome, and test the code out, it gives the wrong behavior(Images do not have the required rounded corner), but when I go to the Developer tools, and mouse hover over the elements tabs (which highlights the various divs in the page), the style is applied correctly, and I get the expected output with rounded corners.
You can test out the behavior on this jsfiddle: http://jsfiddle.net/K9qQ2/2/
The CSS code I have used is as follows:
#map{
border: 6px solid #7AC49F;
border-radius: 30px 30px 30px 30px;
bottom: 0;
display: block;
height: auto;
left: 0;
margin: 39px 10px 10px;
position: absolute;
right: 0;
top: 0;
background-color:#eee;
}
div.olMapViewport {
border-radius: 25px;
}
.olLayerDiv{
border-radius: 25px;
}
So is this a bug? Is there anyway to get Google Chrome to apply the style without going to the developer tools?
Try adding display: block; to the other divs.
It seems to work in jsfiddle.

CSS triangle issue in firefox

I need to use CSS triangle to create and arrow. This is the one Im working on: http://jsfiddle.net/7vRca/
<div class="arrow-outer"></div>
.arrow-outer{
border: 1em solid transparent;
border-top-color: #3bb0d7;
border-right-color: #3bb0d7;
height: 0;
width: 0;
}
The issue is that in chrome it looks perfect. But in firefox there is a small bent in the middle.
Any idea why this is happening and how can I make it look smooth as in chrome?
I haven't got a mac to test unfortunately and Firefox on Windows seems to render correctly. You could get around the problem though...
.arrow-outer {
border: 2em solid transparent;
border-right: 0;
border-top-color: #3bb0d7;
height: 0;
width: 0;
}
Instead of rendering the triangle as two sides of the border, it flattens the right border to achieve the same shape using only the top border, circumventing any alignment issues (illustrated below).
It is possible that Firefox on Mac OS is rendering the div as a pixel height which might be solved using an overflow hidden, but it is equally if not more likely that the rounding in the rendering algorithm has resulted in different pixels being selected for the edge of the right border for that combination of browser and OS. That would be my guess as to why it is happening.
Setting 'inset' for the transparent borders helped for me. I found this trick here: http://css-tricks.com/snippets/css/css-triangle/#comment-103785
Try add this into css:
-moz-transform: scale(.9999);
Try using RGB instead of transparent,
<div class="arrow-outer"></div>
.arrow-outer{
border: 1em solid rgba(255,255,255,0);
border-top-color: #3bb0d7;
border-right-color: #3bb0d7;
height: 0;
width: 0;
}
as we did here: Weird dark border :after css arrow in Firefox
EDIT: by the way, it worsk in both ways in my Firefox (one with the gray line, the others without, but never the effect you described...)

Creating rounded corners using CSS [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
How can I create rounded corners using CSS?
Since CSS3 was introduced, the best way to add rounded corners using CSS is by using the border-radius property. You can read the spec on the property, or get some useful implementation information on MDN:
If you are using a browser that doesn't implement border-radius (Chrome pre-v4, Firefox pre-v4, IE8, Opera pre-v10.5, Safari pre-v5), then the links below detail a whole bunch of different approaches. Find one that suits your site and coding style, and go with it.
CSS Design: Creating Custom Corners
& Borders
CSS Rounded Corners 'Roundup'
25 Rounded Corners Techniques with CSS
I looked at this early on in the creation of Stack Overflow and couldn't find any method of creating rounded corners that didn't leave me feeling like I just walked through a sewer.
CSS3 does finally define the
border-radius:
Which is exactly how you'd want it to work. Although this works OK in the latest versions of Safari and Firefox, but not at all in IE7 (and I don't think in IE8) or Opera.
In the meantime, it's hacks all the way down. I'm interested in hearing what other people think is the cleanest way to do this across IE7, FF2/3, Safari3, and Opera 9.5 at the moment..
I generally get rounded corners just with css, if browser does not support they see the content with flat corners. If rounded corners are not so critical for your site you can use these lines below.
If you want to use all corners with same radius this is the easy way:
.my_rounded_corners{
-webkit-border-radius: 5px;
border-radius: 5px;
}
but if you want to control every corner this is good:
.my_rounded_corners{
border: 1px solid #ccc;
/* each value for each corner clockwise starting from top left */
-webkit-border-radius: 10px 3px 0 20px;
border-radius: 10px 3px 0 20px;
}
As you see in each set you have browser specific styles and on the fourth rows we declare in standard way by this we assume if in future the others (hopefully IE too) decide to implement the feature to have our style be ready for them too.
As told in other answers, this works beautifully on Firefox, Safari, Camino, Chrome.
If you're interested in creating corners in IE then this may be of use - http://css3pie.com/
I would recommend using background images. The other ways aren't nearly as good: No anti-aliasing and senseless markup. This is not the place to use JavaScript.
As Brajeshwar said: Using the border-radius css3 selector. By now, you can apply -moz-border-radius and -webkit-border-radius for Mozilla and Webkit based browsers, respectively.
So, what happens with Internet Explorer?. Microsoft has many behaviors to make Internet Explorer have some extra features and get more skills.
Here: a .htc behavior file to get round-corners from border-radius value in your CSS. For example.
div.box {
background-color: yellow;
border: 1px solid red;
border-radius: 5px;
behavior: url(corners.htc);
}
Of course, behavior selector does not a valid selector, but you can put it on a different css file with conditional comments (only for IE).
The behavior HTC file
With support for CSS3 being implemented in newer versions of Firefox, Safari and Chrome, it will also be helpful to look at "Border Radius".
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
Like any other CSS shorthand, the above can also be written in expanded format, and thus achieve different Border Radius for the topleft, topright, etc.
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 7px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 3px;
-webkit-border-top-right-radius: 10px;
-webkit-border-top-left-radius: 7px;
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 3px;
jQuery is the way i'd deal with this personally. css support is minimal, images are too fiddly, to be able to select the elements you want to have round corners in jQuery makes perfect sense to me even though some will no doubt argue otherwise. Theres a plugin I recently used for a project at work here: http://web.archive.org/web/20111120191231/http://plugins.jquery.com:80/project/jquery-roundcorners-canvas
There's always the JavaScript way (see other answers) but since it's is purely styling, I'm kind of against use client scripts to achieve this.
The way I prefer (though it has its limits), is to use 4 rounded corner images that you will position in the 4 corners of your box using CSS:
<div class="Rounded">
<!-- content -->
<div class="RoundedCorner RoundedCorner-TopLeft"></div>
<div class="RoundedCorner RoundedCorner-TopRight"></div>
<div class="RoundedCorner RoundedCorner-BottomRight"></div>
<div class="RoundedCorner RoundedCorner-BottomLeft"></div>
</div>
/********************************
* Rounded styling
********************************/
.Rounded {
position: relative;
}
.Rounded .RoundedCorner {
position: absolute;
background-image: url('SpriteSheet.png');
background-repeat: no-repeat;
overflow: hidden;
/* Size of the rounded corner images */
height: 5px;
width: 5px;
}
.Rounded .RoundedCorner-TopLeft {
top: 0;
left: 0;
/* No background position change (or maybe depending on your sprite sheet) */
}
.Rounded .RoundedCorner-TopRight {
top: 0;
right: 0;
/* Move the sprite sheet to show the appropriate image */
background-position: -5px 0;
}
/* Hack for IE6 */
* html .Rounded .RoundedCorner-TopRight {
right: -1px;
}
.Rounded .RoundedCorner-BottomLeft {
bottom: 0;
left: 0;
/* Move the sprite sheet to show the appropriate image */
background-position: 0 -5px;
}
/* Hack for IE6 */
* html .Rounded .RoundedCorner-BottomLeft {
bottom: -20px;
}
.Rounded .RoundedCorner-BottomRight {
bottom: 0;
right: 0;
/* Move the sprite sheet to show the appropriate image */
background-position: -5px -5px;
}
/* Hack for IE6 */
* html .Rounded .RoundedCorner-BottomRight {
bottom: -20px;
right: -1px;
}
As mentioned, it has its limits (the background behind the rounded box should be plain otherwise the corners won't match the background), but it works very well for anything else.
Updated: Improved the implentation by using a sprite sheet.
I personally like this solution the best, its an .htc to allow IE to render curved borders.
http://www.htmlremix.com/css/curved-corner-border-radius-cross-browser
In Safari, Chrome, Firefox > 2, IE > 8 and Konquerer (and probably others) you can do it in CSS by using the border-radius property. As it's not officially part of the spec yet, please use a vendor specific prefix...
Example
#round-my-corners-please {
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
The JavaScript solutions generally add a heap of small divs to make it look rounded, or they use borders and negative margins to make 1px notched corners. Some may also utilise SVG in IE.
IMO, the CSS way is better, as it is easy, and will degrade gracefully in browsers that don't support it. This is, of course, only the case where the client doesn't enforce them in non supported browsers such as IE < 9.
Here's an HTML/js/css solution that I did recently. There's a 1px rounding error with absolute positioning in IE so you want the container to be an even number of pixels wide, but it's pretty clean.
HTML:
<div class="s">Content</div>
jQuery:
$("div.s")
.wrapInner("<div class='s-iwrap'><div class='s-iwrap2'>")
.prepend('<div class="tr"/><div class="tl"/><div class="br"/><div class="bl"/>');
CSS:
/*rounded corner orange box - no title*/
.s {
position: relative;
margin: 0 auto 15px;
zoom: 1;
}
.s-iwrap {
border: 1px solid #FF9933;
}
.s-iwrap2 {
margin: 12px;
}
.s .br,.s .bl, .s .tl, .s .tr {
background: url(css/images/orange_corners_sprite.png) no-repeat;
line-height: 1px;
font-size: 1px;
width: 9px;
height: 9px;
position: absolute;
}
.s .br {
bottom: 0;
right: 0;
background-position: bottom right;
}
.s .bl {
bottom: 0;
left: 0;
background-position: bottom left;
}
.s .tl {
top: 0;
left: 0;
background-position: top left;
}
.s .tr {
top: 0;
right: 0;
background-position: top right;
}
Image is just 18px wide and has all 4 corners packed together. Looks like a circle.
Note: you don't need the second inner wrapper, but I like to use margin on the inner wrapper so that margins on paragraphs and headings still maintain margin collapse.
You can also skip the jquery and just put the inner wrapper in the html.
As an indication of how complex it is to get rounded corners working, even Yahoo discourages them (see first bulleted point)! Granted, they're only talking about 1 pixel rounded corners in that article but it's interesting to see that even a company with their expertise has concluded they're just too much pain to get them working most of the time.
If your design can survive without them, that's the easiest solution.
Sure, if it's a fixed width, it's super easy using CSS, and not at all offensive or laborious. It's when you need it to scale in both directions that things get choppy. Some of the solutions have a staggering amount of divs stacked on top of each other to make it happen.
My solution is to dictate to the designer that if they want to use rounded corners (for the time being), it needs to be a fixed width. Designers love rounded corners (so do I), so I find this to be a reasonable compromise.
Ruzee Borders is the only Javascript-based anti-aliased rounded corner solution I've found that works in all major browsers (Firefox 2/3, Chrome, Safari 3, IE6/7/8), and ALSO the only one that works when both the rounded element AND the parent element contain a background image. It also does borders, shadows, and glowing.
The newer RUZEE.ShadedBorder is another option, but it lacks support for obtaining style information from CSS.
If you are to go with the border-radius solution, there is this awesome website to generate the css that will make it work for safari/chrome/FF.
Anyway, I think your design should not depend on the rounded corner, and if you look at Twitter, they just say F**** to IE and opera users. Rounded corners is a nice to have, and I'm personally ok keeping this for the cool users who don't use IE :).
Now of course it's not the opinion of the clients.
Here is the link : http://border-radius.com/
To addition of htc solutions mention above, here're another solutions and examples to reach rounded corners in IE.
There is no "the best" way; there are ways that work for you and ways that don't. Having said that, I posted an article about creating CSS+Image based, fluid round corner technique here:
Box with Round Corners Using CSS and Images - Part 2
An overview of this trick is that that uses nested DIVs and background image repetition and positioning. For fixed width layouts (fixed width stretchable height), you'll need three DIVs and three images. For a fluid width layout (stretchable width and height) you'll need nine DIVs and nine images. Some might consider it too complicated but IMHO its the neatest solution ever. No hacks, no JavaScript.
I wrote a blog article on this a while back, so for more info, see here
<div class="item_with_border">
<div class="border_top_left"></div>
<div class="border_top_right"></div>
<div class="border_bottom_left"></div>
<div class="border_bottom_right"></div>
This is the text that is displayed
</div>
<style>
div.item_with_border
{
border: 1px solid #FFF;
postion: relative;
}
div.item_with_border > div.border_top_left
{
background-image: url(topleft.png);
position: absolute;
top: -1px;
left: -1px;
width: 30px;
height: 30px;
z-index: 2;
}
div.item_with_border > div.border_top_right
{
background-image: url(topright.png);
position: absolute;
top: -1px;
right: -1px;
width: 30px;
height: 30px;
z-index: 2;
}
div.item_with_border > div.border_bottom_left
{
background-image: url(bottomleft.png);
position: absolute;
bottom: -1px;
left: -1px;
width: 30px;
height: 30px;
z-index: 2;
}
div.item_with_border > div.border_bottom_right
{
background-image: url(bottomright.png);
position: absolute;
bottom: -1px;
right: -1px;
width: 30px;
height: 30px;
z-index: 2;
}
</style>
It works quite well. No Javascript needed, just CSS and HTML. With minimal HTML interfering with the other stuff. It's very similar to what Mono posted, but doesn't contain any IE 6 specific hacks, and after checking, doesn't seem to work at all. Also, another trick is to make the inside portion of each corner image transparent so it doesn't block text that is near the corner. The outer portion must not be transparent so it can cover up the border of the non-rounded div.
Also, once CSS3 is widely supported with border-radius, that will be the official best way of making rounded corners.
Don't use CSS, jQuery has been mentioned several times. If you need full control of the background and border of your elements give thejQuery Background Canvas Plugin a try. It places a HTML5 Canvas element in the background and allows yo to draw every background or border you want. Rounded corners, gradients and so on.
Opera does not support border-radius yet (apparently it will be in the release after version 10). In the meantime, you can use CSS to set an SVG background to create a similar effect.