I'm trying to create an email icon in CSS. Is this the right way to code as UI or Front-end Developer?
Check out my Codepen here.
.container {
border-left: 10px solid #80BD9E;
border-right: 10px solid #80BD9E;
background: #F98886;
height: 500px;
width: 500px;
margin: 10% auto;
border-radius: 6px;
}
.arrow-down {
width: 0;
height: 0;
border-left: 250px solid transparent;
border-right: 254px solid transparent;
border-top: 250px solid #80BD9E;
}
.arrow-down1 {
top:22%;
left:25.5%;
width: 0;
height: 0;
border-left: 250px solid transparent;
border-right: 254px solid transparent;
position: absolute;
border-top: 250px solid #f98886;
border-radius:6px;
}
.topLayer {
background: #fff;
position: absolute;
width: 505px;
height: 100px;
margin-left: 24.5%;
margin-top: -9.9%;
z-index: 1;
}
<div class="topLayer">
</div>
<div class="container">
<div class="arrow-down">
<div class="arrow-down1">
</div>
</div>
</div>
Try this. I needed it to embed in an email because imaging is so restrictive:
check it out in action (jsfiddle)
SCSS: size should scale and color will change with a change of the variables
$mail-size: 50;
$letter-color: white;
$letter-accent-color: gray;
.container{
border: $mail-size * .06 + px solid $letter-accent-color;
background-color: $letter-color;
height: $mail-size * 1.4 + px;
width: $mail-size * 2 + px;
border-radius:6px;
}
.arrow-down {
border-left: $mail-size + px solid transparent;
border-right: $mail-size + px solid transparent;
border-top: $mail-size + px solid $letter-accent-color;
}
.arrow-down1 {
margin-top:-$mail-size * 1.008 + px;
margin-left: -$mail-size * .92 + px;
border-left: $mail-size * .92 + px solid transparent;
border-right: $mail-size * .92 + px solid transparent;
border-top: $mail-size * .92 + px solid $letter-color;
border-radius:0px;
}
html
<div class="container">
<div class="arrow-down">
<div class="arrow-down1">
</div>
</div>
</div>
as it turns out, this will not work in email templates either lol
Cool to see that you're trying to be creative with html&css. Like suggested before me it is probebly best/easiest to just use fontAwesome, Material Icons or Bootstrap Icons.
But if you do make icons yourself try to use a 'container-div' with position: relative and all the elements of your icon position: absolute. Right now the email does not render the right way:
Delete the third box. After that this looks fine.
.container {
border-left: 10px solid #80BD9E;
border-right: 10px solid #80BD9E;
background: #F98886;
height: 500px;
width: 500px;
margin: 10% auto;
border-radius: 6px;
}
.arrow-down {
width: 0;
height: 0;
border-left: 250px solid transparent;
border-right: 254px solid transparent;
border-top: 250px solid #80BD9E;
}
.topLayer {
background: #fff;
position: absolute;
width: 505px;
height: 100px;
margin-left: 24.5%;
margin-top: -9.9%;
z-index: 1;
}
<div class="topLayer">
<div class="container">
<div class="arrow-down">
</div>
</div>
</div>
But it's easier to use Font Awesome: http://fontawesome.io/
Related
Here's what I have so far:
.buck-knives-inner-nav {
display: flex;
border: 1px solid #707070;
}
.buck-knives-inner-nav-tab {
text-align: center;
padding: 10px;
width: 100px;
}
.buck-knives-inner-nav-tab:not(:last-child) {
border-right: 1px solid #707070;
}
.active {
background-color: #0B0E55;
color: #ffffff;
}
/*
.active::after {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #0B0E55;
}*/
<div class="buck-knives-inner-nav">
<div class="buck-knives-inner-nav-tab active">
Hold Old is My Knife?
</div>
<div class="buck-knives-inner-nav-tab">
Knife Sharpening
</div>
<div class="buck-knives-inner-nav-tab">
Safety Tips
</div>
<div class="buck-knives-inner-nav-tab">
Knife Care
</div>
<div class="buck-knives-inner-nav-tab">
Choosing the Right Knife
</div>
<div class="buck-knives-inner-nav-tab">
Buck's Forever Warranty
</div>
</div>
I'm wondering - is it possible to style the active tab differently so that it points downward at the bottom center, like I have it in the following mockup?
I tried to implement the downward-facing triangle effect that's used in this article:
https://css-tricks.com/snippets/css/css-triangle/
adding it as an ::after to the active tab - so why didn't that have any effect?
.active::after {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #0B0E55;
}
Also tried something similar - what I found here: Center Triangle at Bottom of Div
All other ideas / suggestions are welcome!
You were missing the position on the after element.
I've added a position: relative; on the buck-knives-inner-nav-tab and some more positioning on the after:
content: "";
position: absolute;
top: 100%;
left: 0;
right: 0;
margin: 0 auto;
.buck-knives-inner-nav {
display: flex;
border: 1px solid #707070;
}
.buck-knives-inner-nav-tab {
text-align: center;
padding: 10px;
width: 100px;
position: relative;
}
.buck-knives-inner-nav-tab:not(:last-child) {
border-right: 1px solid #707070;
}
.active {
background-color: #0B0E55;
color: #ffffff;
}
.buck-knives-inner-nav-tab.active:after {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #0B0E55;
content: "";
position: absolute;
top: 100%;
left: 0;
right: 0;
margin: 0 auto;
}
<div class="buck-knives-inner-nav">
<div class="buck-knives-inner-nav-tab active">
Hold Old is My Knife?
</div>
<div class="buck-knives-inner-nav-tab">
Knife Sharpening
</div>
<div class="buck-knives-inner-nav-tab">
Safety Tips
</div>
<div class="buck-knives-inner-nav-tab">
Knife Care
</div>
<div class="buck-knives-inner-nav-tab active">
Choosing the Right Knife
</div>
<div class="buck-knives-inner-nav-tab">
Buck's Forever Warranty
</div>
</div>
I wanted to create the jigsaw pieces stitched together but not able to achieve the exact shape like below
Currently, I am struck with the below code but not able to achieve the shape
The HTML and CSS code and achieved the design provided below.
<div class="row " style="margin: 0px 5px;">
<div class="col-md bg-color-1">
<p>Some text goes here</p>
</div>
<div class="col-md bg-color-2">
<div class="puzzle"></div>
<p>Some text goes there</p>
</div>
</div>
#CSS
.puzzle {
position: absolute;
left: -27px;
top: 50%;
transform: translateY(-50%);
width: 30px;
height: 40px;
background-color: rgba(255,55,55,.25);
border-top-left-radius: 99px;
border-bottom-left-radius: 99px;
border-top-right-radius: 70px;
border-bottom-right-radius: 70px;
border-left: 3px solid #ff3737;
border-top: 3px solid #ff3737;
border-bottom: 3px solid #ff3737;
}
.bg-color-2 {
background-color: rgba(255,55,55,.25);
border-top: 2px solid #ff3737;
border-right: 2px solid #ff3737;
border-bottom: 2px solid #ff3737;
padding: 15px;
min-height: 250px;
}
.bg-color-2 {
background-color: rgba(255,55,55,.25);
border-top: 2px solid #ff3737;
border-right: 2px solid #ff3737;
border-bottom: 2px solid #ff3737;
padding: 15px;
min-height: 250px;
}
How to get rid of the line at the verge of the two pieces and also getting the curves in the junction?
Any help is appreciated.
Your code didn't for me well so I just quickly created this code.
If you see I created one class called .circle and just add the z-index: -1;
So basically there are two boxes in your code and if you just adjust z-index you'll get the output. Make sure that the left side box has the higher number of z-index and circle has little lower than left box and the right box ( purple in your case) goes low so it has lowest z-index number.
.container {
display: flex;
position: relative;
}
.half-circle {
z-index: -1;
position: absolute;
top: 50%;
transform: translatey(-50%);
height: 50px;
width: 50px;
background-color: pink;
border-radius: 50%;
}
.box {
margin-left: 5%;
height: 200px;
width: 200px;
background: pink;
}
<div class="container">
<div class="half-circle"></div>
<div class="box"></div>
</div>
Let me know if it doesn't work for you.
The webpage displays four arrows top, right, left and bottom; at the top left corner of the screen. I need to align them at the center of the page such that it fits to the page layout without scrolling appearing. Can anyone suggest what I need to do?
Please see the code below:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=yes"/>
<style>
#item_1 {
width: 0;
height: 0;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-bottom: 50px solid #555;
}
#item_2 {
width: 0;
height: 0;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-top: 50px solid #555;
margin-top: 50px;
}
#item_3 {
width: 0;
height: 0;
border-top: 25px solid transparent;
border-right: 50px solid #555;
border-bottom: 25px solid transparent;
margin-top: 50px;
float:left;
}
#item_4 {
width: 0;
height: 0;
align : right;
border-top: 25px solid transparent;
border-left: 50px solid #555;
border-bottom: 25px solid transparent;
float:left;
margin-top: 50px;
}
</style>
</head>
<body>
<div style="float:left; width: 100%">
<div id="item_3"></div>
<div style="float:left">
<div id="item_1"></div>
<div id="item_2"></div>
</div>
<div id="item_4"></div>
</div>
<input type="submit" value="Logout" style="
background: black;
color: #fff;
border: 0px;
padding: 5px;
margin-top: 40px;
">
</body>
</html>
Better not using float, but use position:fixed; with top and left values.
https://www.w3schools.com/css/css_positioning.asp#:~:targetText=An%20element%20with%20position%3A%20fixed,would%20normally%20have%20been%20located.
You might try putting/grouping all of the 4 arrow divs in one single div and do styling on that. I have tried the following code:
CSS
.container
{
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}
HTML
<div class="container">
<div style="float:left; width: 100%">
<div id="item_3" ></div>
<div style="float:left">
<div id="item_1"></div>
<div id="item_2"></div>
</div>
<div id="item_4"></div>
</div>
</div>
Say I've got a div .parent which contains another div .child. Can I, and if so, how do I show an indication (i.e. an icon) when .child exceeds the width of .parent, using CSS?
I've accomplished my goal using jQuery (see below example), but I'm looking for a CSS only solution, as I'm trying to keep my jQuery usage as low as possible.
Note: the .child div has a dynamic width.
Another note: I prefer not to edit the content of the divs
var x = $('.child').offset().left + $('.child').width();
var y = $('.parent').offset().left + $('.parent').width();
if (x > y) {
var z = x - y;
$('.child')
.append($('<div></div>')
.css('left', z - 10)
.css('position', 'absolute')
.css('top', $('.child').height() / 2 - 10)
.text('>'));
}
.parent {
position: relative;
border: 1px solid #000;
height: 200px;
width: 200px;
overflow: hidden;
}
.child {
position: absolute;
top: 40px;
border: 1px solid red;
height: 100px;
width: 400px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div class="parent">
<div class="child">
Some text
</div>
</div>
I read your question and comments. And i had an idea.
Yes i think best way for your problem is use javascript.
But I decided to find alternatives :)
That's why i spent 10 minutes of time on this solution.
Yes it's work only for webkit browsers. But it's possible.
.parent {
position: relative;
border: 1px solid #000;
height: 200px;
width: 200px;
overflow:auto;
}
.child {
position: absolute;
top: 40px;
border: 1px solid red;
height: 100px;
width: 400px;
}
.parent1 {
position: relative;
border: 1px solid #000;
height: 200px;
width: 200px;
overflow:auto;
}
.child1 {
position: absolute;
top: 40px;
border: 1px solid red;
height: 400px;
width: 100px;
}
::-webkit-scrollbar {
background: transparent;
}
::-webkit-scrollbar-button:horizontal:end {
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-right: 8px solid transparent;
border-left:8px solid red;
}
::-webkit-scrollbar-button:vertical:end {
border-left: 8px solid transparent;
border-bottom: 8px solid transparent;
border-right: 8px solid transparent;
border-top:8px solid blue;
}
<div class="parent">
<div class="child">
Some text
</div>
</div>
<div class="parent1">
<div class="child1">
Some text
</div>
</div>
It's been while since I have done some css design work. I have a 3 column lower section marked up in my html like:
<section id="lowerContent">
<section id="lcLeft"></section>
<section id="lcMiddle"></section>
<section id="lcRight"></section>
</section>
I have my css for the sections like this:
section#lowerContent {
width: 958px;
border-left: 1px solid grey;
border-right: 1px solid grey;
height: 405px;
overflow:hidden;
}
section#lcLeft {
width: 216px;
float:left;
height: 100%;
border-right: 1px solid grey;
}
section#lcMiddle {
width: 428px;
float:left;
height: 100%;
border-left: 1px solid grey;
border-right: 1px solid grey;
margin-left: 5px;
}
section#lcRight {
width: 299px;
float: right;
height: 100%;
border-left: 1px solid grey;
margin-left: 5px;
}
If you add up the sections with margins and borders it is 957px so I have 1px to spare inside the lowerContent section. My problem is in IE8 and FF. When I do ctrl + or ctrl - the last div is pushed to the second line and not holding its position. It works correctly in chrome, opera, and safari. Can anyone tell me what I'm missing?
Thanks
My Solution:
First I changed the markup to the following:
<section id="lowerContent">
<section id="lcLeft">
<section id="lcLeftInner"></section>
</section>
<section id="lcMiddle">
<section id="lcMiddleInner"></section>
</section>
<section id="lcRight">
<section id="lcRightInner"></section>
</section>
</section>
The css works for all the major browsers and you can ctrl+ and ctrl - without the layout breaking.
section#lowerContent {
width: 960px;
height: 405px;
}
section#lcLeft {
width: 218px;
height: 100%;
}
section#lcLeftInner {
width: 216px;
border-left: 1px solid grey;
border-right: 1px solid grey;
}
section#lcMiddle {
width: 442px;
height: 100%;
}
section#lcMiddleInner {
width: 430px;
border-left: 1px solid grey;
border-right: 1px solid grey;
margin-left: 5px;
margin-right: 5px;
}
section#lcRight {
width: 300px;
height: 100%;
}
section#lcRightInner {
width: 298px
border-left: 1px solid grey;
border-right: 1px solid grey;
}
Hope that helps someone.
It works correctly in IE8 and FF,too: that's what's supposed to happen when you float those things. When you control+ the page, the floated divs have no place to go but down. If you want them all to line up horizontally, you can give each a z-index; or you can put them in a table.
Try #lcMiddle place after #lcRight and set margin: 0 305px 0 222px and remove float.