h2 span.spacer {
padding:0 5px;
}
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
h2 {
position: absolute;
top: 50px;
left: 0;
}
<h2><span>This is the first line.<span class="spacer"></span><br/><span class="spacer"></span>This is the second line.</span></h2>
Grettings!
So I've developed a funky way of captioning an image as illustrated in the code below. However, as you can see, there are black blocks at the end of the first line and the beginning of the second line which are a darker colour, including the space between the two lines.
Is there any way in which this can be resolved?
Thanks.
h2 span.spacer {
padding:0 5px;
}
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
h2 {
position: absolute;
top: 50px;
left: 0;
}
<h2><span>This is the first line.<span class="spacer"></span><br/><span class="spacer"></span>This is the second line.</span></h2>
Like this?
h2 span.spacer {
padding:0 5px;
}
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
display: inline-block;
}
h2 {
position: absolute;
top: 50px;
left: 0;
}
<h2><span>This is the first line.<span class="spacer"></span><br/><span class="spacer"></span>This is the second line.</span></h2>
try this
h2 span.spacer {
}
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
h2 {
position: absolute;
top: 80px;
left: 0;
}
<h2><span>This is the first line.</span><br/><span>This is the second line.</span></h2>
UPDATE: Removed line between two spans
This, right? Not sure what's happening, when I post this, it shows only plain HTML :/ Hope you're seeing it properly though.
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 9px 10px;
}
h2 {
position: absolute;
top: 50px;
left: 0;
}
<h2><span>This is the first line.</span><br/><span>This is the second line.</span></h2>
Result:
Hope it helps!
Related
I've found out the way to create a border bottom with 2 different colors, but is it possible to have a space between the 2 different colors like the picture shown above?
You will have to tweak the percentages to get the white gap exactly where you want it, but this should get you started.
a {
font-family: sans-serif;
font-size: 36px;
background:
linear-gradient(
to right,
rgba(0, 83, 124,1) 0%,
rgba(0, 83, 124,1) 80%,
rgba(255,255,255,1) 80%,
rgba(255,255,255,1) 82%,
rgba(255, 63, 63,1) 82%,
rgba(255, 63, 63,1) 100%
) bottom left no-repeat;
padding: 6px 0;
text-decoration: none;
background-size: 100% 6px;
color: rgba(0, 83, 124,1);
}
CONTACT US
#font-face {
font-family: "Arial-Bold";
src: url(https://www.cufonfonts.com/download/font/single/48880/arial);
}
h2 {
font-family: "Arial-Bold";
position: relative;
display: inline-block;
color: #1b478d;
text-transform: uppercase;
}
h2::before {
position: absolute;
content: " ";
width: 74%;
left: 0;
bottom: -5px;
height: 5px;
background: #1b478d;
}
h2::after {
position: absolute;
content: " ";
width: 24%;
right: 0;
bottom: -5px;
height: 5px;
background: #e69399;
}
<h2>Contact Us</h2>
You Can Achieve That Using CSS's Border Color Property
h2 {
font-family: sans-serif;
color: #1b478d;
text-transform: uppercase;
}
.txt1 {
border-bottom: 5px solid #1b478d;
margin-right: 4px; /* Space You Want between the Word "Contact" and "Us" */
}
.txt2 {
border-bottom: 5px solid #e69399;
}
<h2>
<span class="txt1">Contact</span><span class="txt2">Us</span>
</h2>
The margin-right property in .txt1 is being used for the space between the both word "Contact" and "Us"
I am trying to change the background color of the header where it says className="NetworkListHeader", but the color is not changing. I want the top portion of the container to be a different color than the body of the container.
HTML code:
class UserNetwork extends Component{
render(){
return(
<div className="UserNetworkContainer">
<div className="NetworkListHeader">
<h2>Your Network</h2>
</div>
<div><li>Object 1</li></div>
<div><li>Object 2</li></div>
<div><li>Object 3</li></div>
</div>
)
}
};
export default UserNetwork;
CSS code:
.UserNetworkContainer{
padding: 10px;
position: absolute;
border-radius: 7px;
top:23%;
right: 73%;
width:23%;
height: 50%;
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.1), 0px 1px 12px 1px rgba(0, 0, 0, 0.17);
}
.NetworkListHeader{
width: 100%;
font-family: Arial, Helvetica, sans-serif;
color: #2C3E50;
font-size: 15px;
margin-left: 70px;
margin-top: 16px;
background-color: blue;
}
The header is in an h2 tag inside that div, so use this selector for your CSS rule:
.NetworkListHeader > h2 {
width: 100%;
font-family: Arial, Helvetica, sans-serif;
color: #2C3E50;
font-size: 15px;
margin-left: 70px;
margin-top: 16px;
background-color: blue;
}
I'm currently trying to add to this python word cloud library a html export (to the existing image one).
The big problem right now is, that the underlying python image library is treating text differently. It draws the "box" around a word at the upper edge of the biggest character of the word. So the box is always as tight as possible to the text.
Browser interpret HTML + CSS differently. They don't make the box as tight as possible, but in a way that all possible characters can fit in. So if the word only consists of lower-case characters the browser will still put some space to the top for the case that there could be upper-case characters.
So my question is now how to achieve a similar behavior with such a "tight" box in CSS.
To illustrate better what I mean, here's an image
In the background you see the resulting png file from the python library, and on top of that the HTML+CSS version. The small white boxes mark the beginning of the box in the png. I put a 50% opacity background around the HTML words to show their box model.
My HTML code for this example is:
<html>
<head>
<link href="https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/html5resetcss/html5reset-1.6.1.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet">
</head>
<body>
<ul style="width:400px; height: 200px; background-image: url(test.png); position: absolute; top:0;left:0;">
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(119, 209, 83); top: 64px; left: 15px; font-size: 102px">hallo</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;transform: rotate(270deg); transform-origin: 50% 90% 0;position: absolute; color: rgb(47, 180, 124); top: 51px; left: 321px; font-size: 73px">ich</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(108, 205, 90); top: 3px; left: 99px; font-size: 61px">test</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(189, 223, 38); top: 142px; left: 114px; font-size: 59px">sie</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(168, 219, 52); top: 37px; left: 50px; font-size: 44px">du</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(31, 161, 135); top: 8px; left: 281px; font-size: 44px">er</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(41, 122, 142); top: 143px; left: 256px; font-size: 44px">es</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(69, 55, 129); top: 149px; left: 17px; font-size: 44px">wir</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(38, 173, 129); top: 34px; left: 241px; font-size: 44px">ihr</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(108, 205, 90); top: 14px; left: 318px; font-size: 41px">und</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(170, 220, 50); top: 1px; left: 2px; font-size: 37px">soll</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;position: absolute; color: rgb(31, 154, 138); top: 167px; left: 227px; font-size: 33px">dann</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;transform: rotate(270deg); transform-origin: 50% 90% 0;position: absolute; color: rgb(67, 62, 133); top: 54px; left: 176px; font-size: 33px">nun</li>
<li style="background-color:rgba(255, 255, 255, 0.5); padding-left: 5.5em; display: inline; list-style: none; margin: 0; padding: 0; font-family: 'Droid Sans Mono', monospace;transform: rotate(270deg); transform-origin: 50% 90% 0;position: absolute; color: rgb(234, 229, 26); top: 71px; left: 128px; font-size: 33px">tun</li>
</ul>
</body>
</html>
I don't think the problem can be solved in pure HTML/CSS, as the box is unaware of the actual characters in it — it just reserves height based on properties in the font.
You could either pick apart the font (using something like opentype.js, looking at the height of the characters in your box and setting its height accordingly. A simpler solution would be to draw your text on a canvas and crop the empty space around it, effectively doing what the Python version does. Downside is that your text is now an image (harder to link or select).
Hello awesome programmers,
I have been struggling greatly with CSS for some time now. I have an issue when resizing a window, some of my divs begin to collapse down the page. (As shown)
Before:
before http://411metrics.com/pics/before.PNG
After:
before http://411metrics.com/pics/after.PNG
I have tried setting the min-width to 100% on various divs and also tried setting the overflow to hidden.
Does anyone have any suggestions as to how to fix this?
My HTML:
<div id="navigation">
<div id="branding-logo"><img src="/Portal/images/sharktek-logo.png" width="35" height="35"></div>
<div id="branding">Sharktek Tracking</div>
<div id="link-wrap">
<div id="active-nav">Dashboard</div>
Reports
Call Logs
Manage Campaigns';
</div>
<div id="nav-user">
Welcome<br>
Account Settings
Logout
</div>
</div>
<div id="nav-accent"></div>
My CSS:
#navigation {
z-index:3;
position: fixed;
top: 0;
width: 100%;
min-width:100%;
color: #ffffff;
height: 60px;
text-align: center;
/* Adds the transparent background */
background-color: rgba(22, 29, 37,1);
color: rgba(1, 172, 237, 1);
}
#navigation a {
float:left;
font-size: 14px;
padding: 25px 25px 0 25px;
color: white;
text-decoration: none;
}
#link-wrap {
float: left;
overflow: hidden;
margin-left: 15%;
}
#active-nav{
z-index: 2;
float:left;
color:white;
height: 60px;
background: -webkit-linear-gradient(#346c83, rgba(1, 172, 237, 1)); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#346c83, rgba(1, 172, 237, 1)); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#346c83, rgba(1, 172, 237, 1)); /* For Firefox 3.6 to 15 */
background: linear-gradient(#346c83, rgba(1, 172, 237, 1)); /* Standard syntax */
}
#active-nav a:hover {
color:white;
}
#navigation a:hover {
color: grey;
}
#branding-logo {
margin-top: 15px;
margin-left: 10px;
float: left;
}
#branding{
margin-top: 20px;
margin-left: 10px;
font-size:1.4em;
color: white;
float: left;
padding: 0px;
}
#nav-accent {
z-index:2;
position: fixed;
top: 60px;
width: 100%;
color: #ffffff;
height: 2px;
padding-top: 1px;
/* Adds shadow to the bottom of the bar */
-webkit-box-shadow: 0px 0px 8px 0px #000000;
-moz-box-shadow: 0px 0px 8px 0px #000000;
box-shadow: 0px 0px 8px 0px #000000;
/* Adds the transparent background */
background-color: rgba(1, 172, 237, 0.95);
color: rgba(1, 172, 237, 1);
}
#nav-user {
color: white;
font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 15px 30px 0 0;
font-size: .8em;
float:right;
}
#nav-user a{
margin: 0;
padding: 0 0 0 10px;
font-size:.8em;
}
I have had similar problems until I started to understand and apply absolute positioning. i.e. positioning relative the div you are in.
For absolute positioning the parent div must be set to relative positioning and after that you fix your inner elements to whatever side you like without having the browser take over the flow control.
e.g. in your case, with ...
#link-wrap {
position: absolute;
width: 500px;
/* ... the rest */
}
... your nav links will stop jumping all over the page. I made a few more tweaks in this fiddle http://jsfiddle.net/xb9cdu34/2/ .
I have some CSS that works well in Chrome, FireFox, and IE, but looks very strange in Opera.
Link to the fiddle
Also, I took screenshots:
This what happens on just forgot link hover:
This happens on form focus (complete disaster):
Normal look in Chrome:
Submit button on focus loses it's border color (why in hell?!)
Some mess on focus, I can't explain, just take a look on second pic
I tested on the latest version of Opera. What the hell is wrong with this browser? Even IE8 shows everything as I expect it.
CSS:
.sign_in {
position: fixed;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -255px;
background: #ffffff;
width: 510px ;
height: 240px;
font-family: Arial,Liberation Sans,DejaVu Sans,sans-serif;
z-index: 9999999;
font-size: 14px;
-webkit-box-shadow: 0 0 5px black;
-moz-box-shadow: 0 0 5px black;
box-shadow: 0 0 5px black;
}
.signs_form{
border-right-style: solid;
border-color: rgba(80, 140, 255, 0.83);
border-width: 1px;
margin-top: 40px;
vertical-align: 100%;
margin-left: 50px;
padding-right: 50px;
font-weight: 500;
display: inline-block;
}
input#email{
border-style: solid;
border-color: #378de5;
border-width: 1px;
padding: 3px 3px 3px 3px;
font-size: 14px;
outline: none;
font-style: normal;
font-weight: 400;
}
input#email:focus{
border-color: rgba(2, 22, 222, 0.97);
}
input#password{
border-style: solid;
border-color: #378de5;
border-width: 1px;
padding: 3px 3px 3px 3px;
font-size: 14px;
outline: none;
font-style: normal;
font-weight: 400;
}
input#password:focus{
border-color: rgba(2, 22, 222, 0.97);
}
.sign_in_submit {
margin-top: 0;
border: solid 1px #378de5;;
background-color: #ffffff;
color: #378de5;
padding: 2px 5px 2px 5px ;
font-family: Arial,Liberation Sans,DejaVu Sans,sans-serif;
font-size: 16px;
font-weight: 500;
}
.sign_in_submit:hover {
cursor: pointer;
border-color: rgba(2, 22, 222, 0.97);
color: rgba(2, 22, 222, 0.97);
}
#close {
float: right;
padding-left:-10px;
padding-top: -10px;
margin-right: 5px;
}
#close_sign_in_popup {
text-decoration: none;
font-family: Arial,Liberation Sans,DejaVu Sans,sans-serif;
font-size: 20px;
color: #d61354;
}
#close_sign_in_popup:hover {
color: #fc145f;
}
.forgot_pass{
display: block;
margin-top: 5px;
margin-bottom: 0;
margin-left: 2px;
font-family: Arial,Liberation Sans,DejaVu Sans,sans-serif;
color: #378de5;
font-size: 13px;
font-weight: 400;
text-decoration: none;
}
.forgot_pass:hover{
height: 100%;
text-decoration: underline;
}
Forked http://jsfiddle.net/w29WQ/1/
.sign_in {
/*top: 50%; // so it seems the positioning gets all funky in opera
left: 50%;*/
margin-top: 0;
margin-left: 0;
/* Your other styles for this element */
}
Anyhow, seems your fixed positioning was causing errors, I simply commented out the top and left positioning in the containing div, and reset the margins to keep the element displayed.
Ok, guys.
1) Shifts in form
The reason is that Opera strongly dislikes inline-block as form property, which is quite logical, actually, but all other browser undertand this and it is convinient
2) Loosing border-color of submit button on field focus
But here - Opera bug, can be fixed by placing before real tag invisible copy - so it is like bait to this Opera bug.