Text in Border CSS HTML
You can do something like this, where you set a negative margin
on the h1
(or whatever header you are using)
div{
height:100px;
width:100px;
border:2px solid black;
}
h1{
width:30px;
margin-top:-10px;
margin-left:5px;
background:white;
}
Note: you need to set a background
as well as a width
on the h1
Example: http://jsfiddle.net/ZgEMM/
EDIT
To make it work with hiding the div
, you could use some jQuery like this
$('a').click(function(){
var a = $('h1').detach();
$('div').hide();
$(a).prependTo('body');
});
(You will need to modify...)
Example #2: http://jsfiddle.net/ZgEMM/4/
Putting text on a border with css?
You CAN NOT make any text in the border. Use div
or something.
Here is the example:
<html>
<head>
<style>
body{margin:0;padding:0;}
.someclass {
width:100%;
height:3em;
background-color:#26282B;
color:white;
}
</style>
</head>
<body>
<div class='someclass'>
Sometext Here
</div>
</body>
</html>
How to make a border-only text in CSS/Javascript
Using text-stroke:
span { font-size: 8rem; color: black; -webkit-text-fill-color: transparent; /* Will override color (regardless of order) */ -webkit-text-stroke-width: 1px; -webkit-text-stroke-color: black;}
<span>ICY</span>
How to have text in the border of a div?
This kind of seems like what you want. You probably need to style it with css though. Another tip: <center>
tags are html4 tags, it would be better to use another <div>
and style it with css instead of the <center>
tags. Anyways I hope this helps.
.certifications h3 { text-align: center;}
.certifications-image { position: relative; margin-top: 20px; margin-right: auto; margin-bottom: 15px; width: 50%; width: 150px; height: 150px; border-radius: 10px;}
.certifications hr { border-color: #68c3a3; margin-left: 20px; margin-right: 20px; padding-bottom: 5px; margin-bottom: 5px;}
.certifications p { margin: 10px; font-size: 18px; text-align: center;}
.certifications-border { border: 2px solid #68c3a3; margin-right: 10px; margin-left: 10px;}
<div class="col-lg-4 certifications-border"> <p>3rd Place</p> <center> <img class="certifications-image" src="assets/images/certification-images/imagineCupLogo.jpg" alt="Sample Image">
<h3>Imagine Cup</h3> <hr/> <p>lorem ipsum text generated</p> </center></div>
How to add border to a text only and align center
Using a span
HTML
<span>Women safty</span>
CSS
body {
text-align: center;
}
span {
border: solid;
}
Result
Using a div, h1 and p
HTML
<h1>Women safty</h1><br /><br />
<div>Women safty</div><br /><br />
<p>Women safty</p><br /><br />
CSS
body {
text-align: center;
}
h1 {
border: solid;
display: inline;
}
div {
border: solid;
display: inline;
}
p {
border: solid;
display: inline;
}
Result
Add text between full border CSS
You could easily use the <fieldset>
and <legend>
elements to do this:
legend { text-align: center;}
<fieldset> <legend>Share with your friends</legend> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex cupiditate tenetur corporis officia corrupti at mollitia quam deleniti minus fuga accusantium, illo aliquid, eaque aperiam voluptatibus ad optio magni hic.</p></fieldset>
CSS Font Border?
There's an experimental CSS property called text-stroke, supported on some browsers behind a -webkit prefix.
h1 { -webkit-text-stroke: 2px black; /* width and color */
font-family: sans; color: yellow;}
<h1>Hello World</h1>
How to make border being behind text? Like this:
The following hopefully fits your needs:
*{
margin: 0;
font-family: Arial, sans-serif;
}
.container {
display: relative;
}
.behind {
height: .75rem;
width: 100%;
position: absolute;
z-index: -1;
top: 1.4rem;
border-radius: .375rem;
background-image: linear-gradient(to right, rgb(201, 157, 201), rgb(110, 202, 224));
}
.container h1 {
position: absolute;
}
<div class="container">
<h1>Stack Overflow
<div class="behind"></div>
</h1>
</div>
How can I place text on an elements border with transparency on the areas where text touches border?
You can achieve this using the pseudo elements
of the h1
tag. In short, you have a wrapper div
that creates the border left, right and bottom and still then use the pseudo elements of h1 to make the top border.
.wrapper {
height: 100px;
margin: 0 auto;
width: 80%;
margin-top: 30px;
box-sizing: border-box;
border: 5px solid tomato;
border-top: none;
position: relative;
}
.wrapper h1 {
position: absolute;
top: -41px;
display: block;
text-align: center;
width: 100%;
overflow: hidden;
font-size: 2em;
}
h1:before,
h1:after {
content: "";
display: inline-block;
width: 50%;
margin-right:1em;
margin-left:-50%;
vertical-align: middle;
border-bottom: 5px solid tomato;
}
h1:after {
margin-right:-50%;
margin-left:1em;
}
/*Demo Only*/
body{
background:url("https://i.imgur.com/fL3tbdj_d.webp?maxwidth=728&fidelity=grand") no-repeat;
background-size:100% 100%;
<div class="wrapper">
<h1>
TITLE HERE
</h1>
</div>
<div class="wrapper">
<h1>
LONGER TITLE HERE
</h1>
</div>
Input border cutout for label cross section
Use fieldset
textarea {
width: 100%;
border: none;
}
<form>
<fieldset>
<legend>Your heading</legend>
<textarea></textarea>
</fieldset>
</form>
Related Topics
Why Is 'Position: Sticky' Not Working With Core Ui'S Bootstrap Css
Which Characters Need to Be Escaped in Html
Add Centered Text to the Middle of a Horizontal Rule
Html5 - Canvas Element - Multiple Layers
≪Embed≫ Vs. ≪Object≫
Why Can't ≪Fieldset≫ Be Flex Containers
How to Customize the Numbers in an Ordered List
Why Is a Div With "Display: Table-Cell;" Not Affected by Margin
Angular 2 Dropdown Options Default Value
Why Does Overflow:Hidden Not Work in a ≪Td≫
How to Send Email from HTML Form
Drop-Down Menu That Opens Up/Upward With Pure Css
What Characters Are Allowed in Dom Ids