Bottom Border to specific section - html

I have a DIV an inside it is a H1 tag with some description , I'm able to give a border-bottom to the whole H1 tag but how to give a border-bottom to just a particular part of it like in the snippet below.
Adding a SPAN tag works, but after giving padding to the border to add space it spreads wrongly breaking the text format.
HTML :
<div class="row">
<div class="col-md-4 text-center" id="column1">
<h3 class="">
<span>Responsive Web Design </span>
</h3>
<br />
<br />
<p>
Coupling aesthetic design sensibilities with.
</p>
</div>
CSS:
#column1 > h3 > span{
border-bottom: 5px solid #16a085;
padding-bottom: 20px;
}
What am I doing wrong here?

I have used :pseudo elemnt to add a border to the element
/** = for better view not required */
.row {
text-align: center;
display: inline-block;
border: 1px solid red;
}
/** = end */
span {
display: block;
position: relative;
padding: 15px 0;
}
span:after {
content: '';
position: absolute;
width: 30px; /* change as per your design */
height: 2px; /* change as per your design */
background: blue; /* change as per your design */
bottom: 0;
left: 50%;
margin-left: -15px;
}
<div class="row">
<div class="col-md-4 text-center" id="column1">
<h3 class="">
<span>Responsive Web Design </span>
</h3>
<br />
<br />
<p>
Coupling aesthetic design sensibilities with.
</p>
</div>

Remove the <span> and the <br> tags and style the <h1> using css to create the spacing above and below the heading. Then add a pseudo element for the line.
The example I'm showing below uses position: absolute on the pseudo element. To ensure that it positions properly make sure the h1 style has position: relative.
.container {
text-align: center;
}
h1 {
position: relative;
margin: 0 0 25px;
padding: 120px 0 25px;
}
h1::before { /* for the graphic */
content: '';
position: absolute;
left: 50%;
top: 0;
transform: translateX(-50%);
display: block;
width: 100px;
height: 100px;
background: transparent url(https://cdn3.iconfinder.com/data/icons/communication-3/512/computer_phone_tablet-512.png) left top no-repeat;
background-size: contain;
}
h1::after { /* for the line below the h1 */
content: '';
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
display: block;
width: 50px;
border-top: 5px solid green;
}
<div class="container">
<h1>Responsive Web Design</h1>
<p>Lorem ipsum dolor sit amet sed umini.Lorem ipsum dolor sit amet sed umini.</p>
</div>

Well, I'm suggesting you to go for the first answer. But if you find this pseudo thing bit confusing, then try the <hr> tag. Give it a fixed width and place it below the title. Simple and clean.
See FIDDLE
#column1 > h3 > span{
padding-bottom: 20px;
}
.text-center hr{
border-bottom: 5px solid #16a085;
width: 50px;
margin: 0 auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-4 text-center" id="column1">
<h3 class="">
<span>Responsive Web Design </span>
</h3>
<hr/>
<br />
<br />
<p>
Coupling aesthetic design sensibilities with.
</p>
</div>

Just set the display property to inline-block like so
display: inline-block;
and then it will work

Related

adding overline and underline with padding and alternate color

As the title says, I'm looking for help with adding lines on top of a header text with a different color than the text. I tried adding padding, margin and color in the class with overline and underline to no effect. Here is my HTML and CSS:
.lines {
text-decoration-line: overline underline;
margin: 20px;
}
<div class="row">
<div class="col-md-7 justify_text">
<h2 class="lines">WHO WE ARE</h2>
<div class="col-md-5">
<img src="img/pic2.jpg" class="img-responsive">
</div>
</div>
</div>
Here is the effect that I want to show:
Another way to do it is to use border properties :
h2 {
display: inline-block;
border-top: 2px solid green;
border-bottom: 2px solid orange;
padding-top: 10px;
padding-bottom: 10px;
}
<h2>WHO WE ARE</h2>
You can use the :after and :before pseudoelemnts to add the lines. Here is an example:
.lines {
position: relative;
padding: 10px 0;
}
.lines:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 30%;
height: 2px;
background: red;
}
.lines:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 30%;
height: 2px;
background: blue;
}
<div class="row">
<div class="col-md-7 justify_text">
<h2 class="lines">WHO WE ARE</h2>
<div class="col-md-5">
<img src="img/pic2.jpg" class="img-responsive">
</div>
</div>
</div>
Hope it helps you.
Another idea with gradient and you will have more flexibility to control colors and sizes:
.lines {
position: relative;
padding: 10px 0;
display:inline-block;
background:
linear-gradient(red,red) top center/100% 2px,
linear-gradient(blue,blue) bottom center/80% 2px;
background-repeat:no-repeat;
}
<h2 class="lines">WHO WE ARE</h2>

How to make the gradient come on top of image and behind the text?

i have been trying to place the grandient on top of the image and behind the text but everything i tried from what i could find out in web didnt worked.
i would need to have the source of the image in the div cause if its in the css code it will apply the same image to all other templates i create.
thanks :)
<div class="titles">
<div class="thumb">
<img class="img overlay"
height=260px
width=240px
alt="Shokugeki no Souma: Ni no Sara"
src="https://img7.anidb.net/pics/anime/184719.jpg" />
<div class="titulo">Shokugeki no Souma: Ni no Sara</div>
<div class="epis">Epis. 12</div>
</div>
.titles .thumb {
position: relative;
float: left;
height: 260px;
width: 245px;
max-height: 260px;
max-width: 260px;
margin: 0 auto;
padding: 5px;
}
.thumb .titulo {
position: absolute;
bottom: 0;
left: 0;
padding: 8px;
margin: 5px;
font-size: 15px;
font-weight: bold;
color: white;
}
.thumb .epis {
position: absolute;
top: 0;
right: 0;
padding: 8px;
margin: 10px;
font-size: 15px;
font-weight: bold;
color: white;
}
.titles .thumb .img:hover {
max-height: 260px;
max-width: 260px;
height: 260px;
width: 240px;
opacity: 0.8;
}
.img.overlay {
background: linear-gradient(
to bottom,
black,
rgba(64,64,64,1),
rgba(64,64,64,1),
rgba(64,64,64,1),
rgba(64,64,64,1),
rgba(64,64,64,1),
rgba(64,64,64,1),
black);
}
Do you mind explaining a bit more about what is going wrong when you try to implement this?
My suggestion would be to put the overlay in its own separate div instead of inside the image tag. Then close the overlay div before you start your caption div. Then you can set your "thumb" class to have a certain width and height in your css, and style the overlay div to have height:100% width:100%so that it completely covers your thumbnail image. If you absolutely position the caption text, you can place it on top of the gradient. For example
<div class="titles">
<div class="thumb">
<img alt="Shokugeki no Souma: Ni no Sara" src="https://img7.anidb.net/pics/anime/184719.jpg" />
<div class="overlay"></div>
<div class="titulo">Shokugeki no Souma: Ni no Sara</div>
<div class="epis">Epis. 12</div>
</div>
</div>

Is there a semantically better way to create this layout of text in circles?

I've come up with what seems like a very hacky, non-semantic way to code a design that I'd like to use. Basically, it's a set of 4 equal-sized circles, distributed so their centers are the same as those of equilateral triangles. I've used a bunch of presentational divs to solve two issues: (1) to get the spacing of the circles right, I need their bounding boxes to overlap; and (2) to vertically space text in the circles without changing their size, it seems like I need to use display:table in my CSS.
It works, but I hate it, and I feel like there has to be a better way. I am new to CSS, and this method is the result of a fair amount of research about how to solve this design problem.
The design is at this codepen: http://codepen.io/bhagerty/pen/rejEPZ
(I put borders on a bunch of the elements just to show the structure.)
Here is the HTML:
<body>
<h1 id="home_title">test</h1>
<div id="container_1">
<div id="picture" class="box">
<div class="circle_outer">
<div class="circle_inner">
<div class="inner-text">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/%22In_Which_We_Serve%22_Advertisement_1943.jpg/1024px-%22In_Which_We_Serve%22_Advertisement_1943.jpg" width=100%; />
</div>
</div>
</div>
</div>
<div id="dog" class="box">
<div class="circle_outer">
<div class="circle_inner">
<div class="inner-text">
dog
</div>
</div>
</div>
</div>
<div id="shoes" class="box">
<div class="circle_outer">
<div class="circle_inner">
<div class="inner-text">
shoes
</div>
</div>
</div>
</div>
<div id="dance" class="box">
<div class="circle_outer">
<div class="circle_inner">
<div class="inner-text">
dance
</div>
</div>
</div>
</div>
<div id="footer_1">
Footer<br>
test
</div>
</div>
</body>
Here is the CSS:
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-size: 16px;
}
h1#home_title {
text-align: center;
font-size: 3rem;
margin: 0;
padding: .1rem 0 .5rem 0;;
background-color: grey;
}
div#container_1 {
border: green solid 5px;
width: 320px;
margin: auto;
position: relative;
}
div.box {
border: red solid 1px;
position: absolute;
width: 53.6%;
text-align: center;
background-color: transparent;
}
/*pseudo-element to give relative height,
per http://jsfiddle.net/simevidas/PFPDU/
and http://www.mademyday.de/css-height-equals-width-with-pure-css.html */
div.box::before {
content: "";
display: block;
padding-top: 100%;
height: 0;
}
/* if inner text has position relative, it influences the size of the containing box */
/*setting all of the positions to zero forces it inside the circle for some reason */
.circle_outer {
position: absolute;
overflow: hidden;
border: black solid 2px;
border-radius: 50%;
/* to create breathing room all around, set top and left to 1/2 of 100% - width (where width = height) */
top: 5%;
left: 5%;
width: 90%;
height: 90%;
}
.circle_inner {
/* border: grey solid 5px; */
display: table;
width: 100%;
height: 100%;
}
.inner-text {
display: table-cell;
/* border: green solid 2px; */
font-size: 2em;
vertical-align: middle;
}
/*First bounding box is at upper left corner */
div#picture {
overflow: hidden;
left: 0;
margin-top: 0;
}
/*Percent positions all based on W, derived from fact
that bounding boxes circumscribe tangent circles, and
circle centers are connected by equilateral triangles */
div#dog {
left: 46.4%;
margin-top: 26.8%;
}
div#shoes {
left: 0;
margin-top: 53.6%;
}
div#dance {
left: 46.4%;
margin-top: 80.4%;
}
div#footer_1 {
border: red solid 2px;
position: relative;
width: 100%;
left: 0;
margin-top: 137%;
text-align: center;
background-color: blue;
}
I much appreciate any thoughts or help. Thanks!
Well, IMO what you've done is really good. I wouldn't be too concerned about the extra divs.
But, it can be done with fewer divs, making use of float and margins.
Codepen is here
html {
font-size: 16px;
}
h1#home_title {
text-align: center;
font-size: 3rem;
margin: 0;
padding: .1rem 0 .5rem 0;;
background-color: grey;
}
div#container_1 {
border: green solid 5px;
width: 320px;
margin: auto;
position: relative;
box-sizing: border-box;
}
div.box {
border: red solid 1px;
position: relative;
float:left;
width: 53.6%;
text-align: center;
background-color: transparent;
box-sizing:border-box;
margin-bottom:-27%;
}
div.box:nth-child(2n) {
float:right;
}
div.box:nth-child(2n+1) {
float:left;
}
/*pseudo-element to give relative height,
per http://jsfiddle.net/simevidas/PFPDU/
and http://www.mademyday.de/css-height-equals-width-with-pure-css.html */
div.box::before {
content: "";
display: block;
padding-top: 100%;
height: 0;
}
/* if inner text has position relative, it influences the size of the containing box */
/*setting all of the positions to zero forces it inside the circle for some reason */
.featuring {
position: absolute;
overflow: hidden;
border: black solid 2px;
border-radius: 50%;
/* to create breathing room all around, set top and left to 1/2 of 100% - width (where width = height) */
top: 5%;
left: 5%;
width: 90%;
height: 90%;
font-size: 2em;
}
.featuring:before {
content:'';
margin-left:-0.25em;
display:inline-block;
vertical-align:middle;
height:100%;
}
/*Percent positions all based on W, derived from fact
that bounding boxes circumscribe tangent circles, and
circle centers are connected by equilateral triangles */
div#footer_1 {
border: red solid 2px;
position: relative;
width: 100%;
left: 0;
margin-top: 137%;
text-align: center;
background-color: blue;
clear:both;
}
<body>
<h1 id="home_title">test</h1>
<div id="container_1">
<div id="picture" class="box">
<div class="featuring">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/%22In_Which_We_Serve%22_Advertisement_1943.jpg/1024px-%22In_Which_We_Serve%22_Advertisement_1943.jpg" width=100%; />
</div>
</div>
<div id="dog" class="box">
<div class="featuring">
dog
</div>
</div>
<div id="shoes" class="box">
<div class="featuring">
shoes
</div>
</div>
<div id="dance" class="box">
<div class="featuring">
dance
</div>
</div>
<div id="footer_1">
Footer<br>
test
</div>
</div>
</body>

trouble creating a box-shadow type effect with divs

I'm trying to create a solid box-shadow type effect without using CSS3. I'm constrained by a rich text editor's inflexible nature, and the need to have all styling in-line
Essentially, I need to place one div over another, slightly offset down, and right, div and have both centered and expand vertically with the amount of text I place withinin the top div.
I've included my best try at making it work here: jsfiddle example
CSS :
#firstDiv {
clear:left;
margin-top:30px;
padding: 0 30 0 30;
}
#secondDiv {
display: table;
clear:left; position: relative;
margin:auto;
width:70%;
padding:60 50 60 20;
background: #ccc;
}
#thirdDiv {
width:100%;
position: absolute;
top: -20px;
bottom: 20px;
right: 20px;
padding: 20px;
background: #fff;
border: 2px solid #ccc;
clear: left;
}
HTML :
<div id="#firstDiv">
<div id="#secondDiv">
<div id="#thirdDiv">
<!--My long Text-->
<p style="text-align: center">Lorem ipsum ...</p>
<p style="text-align: center">Lorem ipsum ...</p>
<p style="text-align: center">Lorem ipsum ...</p>
<p style="text-align: center">Lorem ipsum ...</p>
<p style="text-align: center">Lorem ipsum ...</p>
</div>
</div>
</div>
Unless I'm missing something...this should suit you very fine. Just insert this css inline in your html. http://jsfiddle.net/XfPNB/3/
We cannot use pseudo-elements (inline css restricts us). So, just add some div to the one containing all your text/content. Set position: relative; on your top div, then on the one that will be its shadow:
background: grey;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
Basically make sure it's exactly the same size as your main div, and then put it /under/ it (z-index). Grey (or yellow?) background. That's your shadow.
I was able to achieve your desired effect with two relative DIVs:
<div style="width: 70%; margin: 30px auto; position: relative; background-color: #ccc;">
<div style="position: relative; top: -20px; right: 20px; bottom: 20px; left: -20px; padding: 20px; background: #fff; border: 2px solid #ccc;">
JSFiddle

Responsive diamond grid

I have a selection of squares (squares turned 45° to look like diamonds) which I want to use to make up a big diamond shape with a central red diamond.
I am having issues organising the diamonds themselves and the href seems to fail.
How do I position the responsive diamonds in a regular grid?
Her is my code:
body {
background: black;
color: #000000;
font: 13px georgia, serif;
line-height: 1.4;
font-weight: lighter;
text-rendering: optimizelegibility;
}
#diamond {
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom-color: white;
position: relative;
top: -50px;
}
#diamond:after {
content: '';
position: absolute;
left: -50px;
top: 50px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: white;
}
#diamond_red {
width: 0;
height: 0;
border: 50px solid transparent;
border-bottom-color: #AA1C08;
position: relative;
top: -50px;
}
#diamond_red:after {
content: '';
position: absolute;
left: -50px;
top: 50px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: #AA1C08;
}
<a class="navigation">
<center>
<div id="diamond"></div>
<div id="diamond"></div>
<div id="diamond" href="/photos/"></div>
<div id="diamond_red"></div>
<div id="diamond" href="/projects/"></div>
<div id="diamond"></div>
<div id="diamond"></div>
<div id="diamond" href="/archive/"></div>
</center>
</a>
The responsive grid of diamons:
I don't think you have the right aproach to achieve a regular responsive diamond grid layout. It would be much simpler to:
create a responsive grid of squares (3x3 or whatever grid you feel like)
then rotate the grid 45 degrees.
That way you won't have to fiddle with borders, pseudo elements (:after, :before) and positioning each diamond.
Here is a responsive example
It uses percentage width and padding-bottom to keep the diamonds responsive and transform:rotate(45deg); to rotate te whole grid and make it look like a diamond grid:
body{background:#000;}
#big_diamond {
width: 50%;
margin:15% auto;
overflow:hidden;
transform: rotate(45deg);
}
.diamond {
position: relative;
float: left;
width: 31.33%;
padding-bottom: 31.33%;
margin: 1%;
background: #fff;
transition:background-color .4s;
}
.diamond a {
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
}
#red{background-color: #AA1C08;}
.diamond:hover, #red:hover{background-color:darkorange;}
<div id="big_diamond">
<div class="diamond"></div>
<div class="diamond"></div>
<div class="diamond"></div>
<div class="diamond"></div>
<div class="diamond" id="red"></div>
<div class="diamond"></div>
<div class="diamond"></div>
<div class="diamond"></div>
<div class="diamond"></div>
</div>
As other people have mentioned, there are some errors in your HTML that I corrected like: Ids need to be unique and href can't be used on divs.
You're going to need to be more specific / clear on your first question.
First of all, you are using the ID 'diamond' many times. IDs are meant to be unique and used for one element. You should be using classes for this, not IDs.
Second, you can't use href within div tags. You could wrap the divs in a tags like this:
<div class="diamond"></div>
Or, even better so that the whole shape is clickable you can put the a inside of the div and make the a a block level element that is 100% width and height like this:
<div class="diamond"></div>
div a{
width: 100%;
height: 100%;
display: block;
}
JSFiddle Example: http://jsfiddle.net/kQj24/1/
This html has fallback for browsers that don't support transform in that the diamond becomes a square. Also the <div> elements can be wrapped in <a> tags using this method without altering any existing css rules for a. If transform isn't supported the text inside the square class doesn't rotate either.
<center>
<div class="diamond">
<div class="row">
<div class="square"><p>Text</p></div>
<div class="square"></div>
<div class="square"><p>Text</p></div>
</div>
<div class="row">
<div class="square"><p>Text</p></div>
<div class="square red"><p>Text</p></div>
<div class="square"><p>Text</p></div>
</div>
<div class="row">
<div class="square"><p>More</p></div>
<div class="square"></div>
<div class="square"><p>Text</p></div>
</div>
</div>
</center>
CSS, using your existing body rule:
.diamond {
padding-top: 50px;
transform:rotate(45deg);
-ms-transform:rotate(45deg);
-webkit-transform:rotate(45deg);
}
.square {
background-color: white;
display: inline-block;
height: 50px;
overflow: hidden;
width: 50px;
}
.square:hover {
background-color: green;
}
.square p {
transform:rotate(-45deg);
-ms-transform:rotate(-45deg);
-webkit-transform:rotate(-45deg);
}
.red {
background-color: red;
}
http://jsfiddle.net/5Q8qE/8/