How can I get the element in the attached pic?
I need a line + curve to right at top + extension.
I can use div's, span or another idea if you have.
I tried to use 2 divs with round borders. But they don't connect in a pretty way in the corner.
I assume you mean the dot in the corner. It's not particularly robust to change, and it will currently only work on a white background. However, with some SCSS and variables, it would be a lot cleaner.
The biggest issue I have with it is that the surrounding box is required to have a relative position, which might affect layout elsewhere.
.fancy {
position: relative;
padding: 12px;
border: 3px solid #ccc;
border-radius: 8px;
}
.fancy::after {
position: absolute;
bottom: -11px;
left: -11px;
content: "";
height: 14px;
width: 14px;
display: inline-block;
border: 4px solid white;
border-radius: 11px;
background-color: gray;
}
p {
font-family: Arial;
font-size: 14px;
}
<p class="fancy">
Some text
</p>
The padding around the dot is given by the border-width (4px).
The colour of the dot is defined by the background-color.
The places where 11px is used are computed by the border-width + the [height (or width) / 2] and used to keep the dot circular and in the corner.
It's a little ambiguous what you want. If you wanted the title block in there too, then add this:
.fancy {
position: relative;
padding: 12px;
border: 3px solid #ccc;
border-radius: 8px;
}
.fancy .title {
display: table;
margin-top: -2.2em;
margin-bottom: 0.2em;
padding: 6px 8px;
border: 6px solid white;
border-radius: 12px;
background-color: #99ccff;
}
p {
font-family: Arial;
font-size: 14px;
}
<p class="fancy">
<span class="title">A fancy title</span>
Some text with a fancy title.
</p>
Related
In my nav, I am separating my section with some text and a horizontal line. For each section this repeats. I am doing this as shown below:
.navSectionHeader {
font-size: 1em;
color: #fff;
margin-left: 5px;
margin-bottom: 10px;
font-family: "Roboto";
font-weight: 700 !important;
border-bottom: 2px solid #6c6c6c;
}
/*.navSectionHeader::after {
content: ' ';
display: block;
border: 2px solid;
border-color: #6c6c6c;
margin-left: 0px !important;
}*/
The issue is, my text is now pretty much stuck to the left of the parent div. It should be with some margin to the left while keeping the bottom border start from 0px to the left. When I try to move it with margin-left: 5px; it ends up moving the border-bottom as well. I tried this with ::after as shown in the commented bit, adding !important to the end but nothing changes. Am I doing this the wrong way? Sorry, I'm a front-end noob!
Edit: The section header is in a <span> if it makes a difference.
Use padding instead of margin.
.navSectionHeader {
padding-left: 5px;
}
An example to see difference,
div {
display: inline-block;
width: 100px;
height: 20px;
border-bottom: 1px solid black;
background: red;
color: white;
}
.padding {
padding-left: 5px;
}
.margin {
margin-left: 5px;
}
<div class="margin">margin</div><br>
<div class="padding">padding</div>
I'm trying to use CSS and HTML to create a text underline that's curved. The curve in particular has been referred to as a "swoosh" in the design brief I was given, it needs to fall short of the first and last letter (i.e. to underline "help you", it would start at "e" and end at "o" - this part I figure is easy, applying the style to a span tag without the first and last letter), and has to have rounded ends. The swoosh is also not even.
Here's an example:
I'm not super crash hot with CSS, but I know I'm constrained to CSS and HTML in this case - no HTML5 or using javascript to get it done.
So far, I've only managed to come up with this:
.swoosh1 {
width: 500px;
height: 100px;
border: solid 5px #cb1829;
border-color: #cb1829 transparent transparent transparent;
border-radius: 50%/100px 100px 0 0;
}
Which looks like this (don't worry about the font): :(
Does anyone have any pointers? Done it before?
You can use :after pseudo-element to hold your underline:
.underlined {
position: relative;
margin-right: 1rem;
}
.underlined:after {
content: "";
position: absolute;
bottom: -10px;
left: 0;
height: 7px;
width: 100%;
border: solid 2px #cb1829;
border-color: #cb1829 transparent transparent transparent;
border-radius: 50%;
}
.small {
font-size: 60%;
}
.big {
font-size: 200%;
}
<span class="underlined">Test</span>
<span class="underlined small">Test</span>
<span class="underlined big">Test</span>
Use :after and then use border and radius and position it
Learn about pseudo:https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
.text:after{
content: "";
position: absolute;
height: 15px;
width: 70px;
left: 5px;
top: 37px;
border-top: 2px solid red;
border-radius: 50%;
}
.text{
font-family: "Comic Sans MS", cursive, sans-serif;
color:red;
}
<p class="text">Your local</p>
make sure to use : display: inline-block !important; on underlined class to be responsive.
Without : display: inline-block !important; on underlined class, it will as below on device.
.underlined {
position: relative;
display: inline-block !important;
}
.underlined::before {
content: "";
position: absolute;
bottom: -12px;
left: 0;
height: 7px;
width: 100% !important;
border: solid 8px yellow;
border-color: yellow transparent transparent transparent;
border-radius: 50%;
}
.big {
font-size: 50px;
}
<h1 class="big "> You're connected. Now, <span class="underlined "> automate!</span> </h1>
I was trying to create a circle with i icon in it for with CSS. However, when page is first rendered the circle looks like an inverted egg and covers the border around it slightly. (Zoom in the browser to see issue in more details)
The tricky part is, if you open Dev Tools and change any value related to it's position(width, height, whatever), everything will snap back to normal and it will become a circle.
https://jsfiddle.net/2yjashje/
<div class="round-egg">
i
</div>
.round-egg {
font-size: 14px;
background: white;
color: #8DC641;
border-radius: 10px;
cursor: help;
border-bottom: none !important;
border: 4px solid #8DC641;
width: 20px;
height: 20px;
text-align: center;
}
What is going on here?
I put the letter "i" in its own span and increased the margin from top to vertically centre it. As for the circle, I modified the border-radius property, and then removed the border-bottom: none; property as well. Assuming you want a circle, you need the bottom border.
https://jsfiddle.net/2yjashje/3/
<div class="round-egg">
<span class="icon">i</span>
</div>
.round-egg {
font-size: 14px;
background: white;
color: #8DC641;
border-radius: 30px;
cursor: help;
border: 4px solid #8DC641;
width: 20px;
height: 20px;
text-align: center;
display: table-cell;
}
.icon {
display: block;
margin-top: 2px;
}
I am trying to create the appearance of a text chat using pure CSS. The kind of text chat where one person's texts are represented by speech bubbles on the left of the screen, and the other persons are speech bubbles on the right side of the screen.
I'm almost there, and I've created a JSFiddle example. There are two problems.
The big problem is that the bubbles with the pointer on the right side, representing the person on the right, needs to be aligned on the right side. But I can't find a way to get them to align without floating them, and if I float them, then they overlap with other bubbles and create a mess.
How do I get the class bubble-right to stick to the right side?
The second issue is that I'm using display: inline-block; which makes it so that the bubbles are only as wide as the text. I had to put white-space: pre-line; in the containing DIV in order to get the bubbles to stack properly. Unfortunately, this is creating extra space. I tried putting in line-height declarations to prevent this, but it doesn't seem to have helped.
How do I get the bubbles to stack and alternate vertically without making extra whitespace I don't need?
Here is the CSS:
.bubble-dialog {
white-space: pre-line;
line-height:0;
}
.bubble-left,
.bubble-right {
line-height: 100%;
display: inline-block;
position: relative;
padding: .25em .5em;
background: pink;
border: red solid 3px;
-webkit-border-radius: 11px;
-moz-border-radius: 11px;
border-radius: 11px;
margin-bottom: 2em;
}
.bubble-left {
margin-right:10%;
}
.bubble-right {
margin-left:10%
}
.bubble-left:after,
.bubble-left:before,
.bubble-right:after,
.bubble-right:before {
content: "";
position: absolute;
top: 21px;
border-style: solid;
border-width: 13px 17px 13px 0;
border-color: transparent pink;
display: block;
width: 0;
}
.bubble-left:after,
.bubble-left:before {
border-width: 13px 17px 13px 0;
border-color: transparent pink;
}
.bubble-right:after,
.bubble-right:before {
border-width: 13px 0 13px 17px;
border-color: transparent pink;
}
.bubble-left:after {
left: -16px;
border-color: transparent pink;
z-index: 1;
}
.bubble-left:before {
left: -19px;
border-color: transparent red;
z-index: 0;
}
.bubble-right:after {
right:-16px;
border-color: transparent pink;
z-index: 1;
}
.bubble-right:before {
right:-19px;
border-color: transparent red;
z-index: 0;
}
I don't understand your second problem very well, but as for first problem you can add this css to your left and right classes:
I add clear:both and display:block and add float as you said, and right bubbles will stick at right side; here is a fiddle:
.bubble-left,
.bubble-right {
line-height: 100%;
display: block;
position: relative;
padding: .25em .5em;
background: pink;
border: red solid 3px;
-webkit-border-radius: 11px;
-moz-border-radius: 11px;
border-radius: 11px;
margin-bottom: 2em;
clear: both;
max-width:50%;
}
.bubble-left {
float: left;
margin-right:10%;
}
.bubble-right {
float:right;
margin-left:10%
}
And as for your second problem, I don't know why the spaces are there, but with removing bottom margin of the <p> tag it gets OK so I add margin-bottom:0 to <p> tag;
I have been able to create the tooltips for my app. The tooltips content will comes from a DB and it is dynamic. Sometimes it will have two lines of text and sometimes it will have five lines of text. I am struggling to keep the position fixed regardless of what the content is. Is there anything I can try to fix this?
Here is a fiddle demonstrating what I am facing.
.tooltip:hover .dumClass {
display: inline;
color: #ffffff;
border: 1px solid #DCA;
background: #444;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
}
enter code here
CSS
.tooltip{position:relative;}
.tooltip .dumClass {
z-index: 10;
display: none;
padding: 14px 20px;
bottom:20px;
left:0;
width: 240px;
line-height: 16px;
position: absolute;
}
DEMO