I'm in the process of doing a redesign of my site. Maybe someone could be so kind to shed some light on an issue I am having.
Below is a mock up of what I'm trying to do. I am using font awesome to create icons and would like to put a border round each icon.
I have tranlated the mock-up into the following HTML code
<div class="col-md-4">
<p class="servicesFont borderSer"></p>
</div>
<div class="col-md-4">
<p class="servicesFont borderSer"></p>
</div>
<div class="col-md-4">
<p class="servicesFont borderSer"></p>
</div>
And CSS
.servicesFont{
font-family: FontAwesome;
color: #3397d3;
font-size: 90px;
font-weight: 400;
display:inline-block;
}
.borderSer{
border-radius: 50%;
border-width: .25em;
border-color: #885fa8;
border-style: dashed;
display:inline-block;
}
With this code I am getting the following results;
I am not using the font awesome classes as I was having issues specifying sizes using that method. Maybe I should do it with the classes?
I would greatly appreciate it if someone could give me an idea on now to best implement that icons on the mock-up.
You really should use the classes for both accessibility reasons and SEO. If you place the character codes directly in your markup a screen reader will read out "&-#-x-f-1-0-8-;", which obviously will be confusing and non-sensical to someone who isn't sighted. Moreover, you have the character codes in your markup and wrapped in a p tag, so you're telling search engines that those codes are content.
Here's one way to correctly use the classes instead:
.services {
padding-top: 2em;
padding-bottom: 2em;
}
.services i, .services h4 {
text-align: center;
}
.fa.services-icon {
color: #3397d3;
height: 180px;
width: 180px;
font-size: 90px;
line-height: 180px;
margin: auto;
display: block;
}
.services-icon:after {
content:'';
position: absolute;
top: 0;
left: 0;
height: 180px;
width: 180px;
border-radius: 50%;
border-width: .25em;
border-color: #885fa8;
border-style: dashed;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="container">
<div class="row services">
<div class="col-sm-4">
<i class="fa fa-desktop services-icon"></i>
<h4>Web</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque a nisi ac neque interdum pharetra sit amet in tortor. Curabitur sit amet nisi non felis sodales placerat non quis urna. Proin eget metus dui. Vestibulum finibus justo vel erat volutpat bibendum. Donec pretium tortor eget dui efficitur, in dapibus lorem lobortis.</p>
</div>
<div class="col-sm-4">
<i class="fa fa-newspaper-o services-icon"></i>
<h4>Print</h4>
<p>Curabitur aliquet lacus nec leo iaculis, in luctus velit finibus. Donec pharetra rutrum orci malesuada dapibus. Vivamus sit amet bibendum lectus. Nulla sagittis dolor quis odio suscipit, sed euismod lorem euismod. Donec dapibus vitae libero faucibus bibendum. Duis aliquet nisi a ligula hendrerit, a ullamcorper tellus tincidunt.</p>
</div>
<div class="col-sm-4">
<i class="fa fa-pencil services-icon"></i>
<h4>Branding</h4>
<p>Nam tempus luctus laoreet. Cras at massa sapien. Vivamus eu rhoncus sapien, ac molestie urna. Suspendisse malesuada ligula vitae augue sodales finibus. Vestibulum porttitor sed elit ac vestibulum. In feugiat ipsum sed elit consequat, id vehicula odio pellentesque. Proin sit amet dictum velit. Etiam sit amet lorem quis leo laoreet pellentesque.</p>
</div>
</div>
</div>
Thank you ckuijjer. Below is the result from adding a fixed with span element.
HTML
<span class="width borderSer">
<p class="servicesFont "></p>
</span>
CSS
.servicesFont{
font-family: FontAwesome;
color: #3397d3;
font-size: 90px;
font-weight: 400;
display:inline-block;
padding:20px;
}
.borderSer{
border-radius: 50%;
border-width: 25px;
border-color: #885fa8;
border-style: dashed;
display:inline-block;
text-align:center;
}
.width{
width:200px;
height:200px;
}
Result
If anyone could give me any suggestions on how to do this better it would be greatly appreciated.
Thanks
Since height and width of the icon are not of same pixel. You can get the border to not clearly circle. For that you can manage by:
1)Giving more padding to the parent element's left and right side if your icon has more height than width and vice versa.
2) Since you cannot apply height and width property to font icon you can make parent height and width equal like done in above answer.
Related
I'm making a div that needs to be fixed, 100% height and vertically center aligned. And it has to be done with Bootstrap 4. I've managed all of that, except adding padding. Whenever I add padding to the child div, the content goes offscreen. I've even tried
overflow-y: scroll
hoping it'll fix it, but nothing happens.
Because the code snipped is not showing everything as it should on here, here's a codepen link.
Can someone please take a look at my code and let me know what I did wrong?
.card {
color: #fff;
background: tomato;
position: fixed;
min-height: 100%;
/* height: 100%; */
width: 340px;
right: 0;
top: 0;
overflow: scroll;
}
.card-block {
padding: 100px;
margin: auto;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<div class="card rounded-0 d-flex justify-content-center">
<div class="card-block align-self-center">
<h1>This is a title</h1>
<h5>This is a subtitle</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in laoreet neque. Praesent tincidunt justo a magna tempor vulputate. Phasellus euismod feugiat sem. Nam tempus nec nisl id viverra. Cras blandit erat mauris. Cras non commodo quam. Mauris
auctor ligula vitae erat mollis, quis convallis diam consequat. Nullam ac magna vitae lorem elementum vehicula nec rhoncus nisl. Nullam dignissim at nunc a congue. Sed fringilla pulvinar consequat. Curabitur interdum, nunc in finibus auctor, tortor
libero facilisis felis, id maximus nibh ex eu nunc. Nunc in molestie lorem, bibendum maximus ipsum. Vestibulum ac finibus risus.</p>
This is a button
</div>
</div>
Just add bottom:0 to your class card-block
You need to add the properties just to card-block and not card
.card-block {
padding: 0px 40px;
margin: auto;
color: #fff;
background: tomato;
position: fixed;
width: 340px;
top: 0;
bottom:0;
right: 0;
overflow-y: scroll;
}
Feel free to change padding,margin and width. As they will still keep the scrolling intact.
Check this CODEPEN
I have this fixed right side bar layout working perfectly for me for a long time, it works in most of the browsers and devices too.
But the recent chrome update to 45 which happened few days ago, broke the layout by adding a horizontal scrollbar.
There are different ways to achieve the fixed right side bar layout, but this layout needs to extend the background color of main and side columns to the browser width extent with fixed max-width container(marked in red) and with shadow between columns.
And this below code was the best way I could achieve it.
Now all I need is no scrollbar in Chrome 45, I tried different ways to avoid it but none works. I know this wont be a easy fix, but any help on this would be appreciated.
http://jsfiddle.net/chetanjk/ptuxn2dq/
HTML
<div class="container" style="background:#000; color:#fff; text-align:center">
------page content max width for reference ----
</div>
<div class="page-cols">
<div class="container ">
<div class="cols-wrap">
<section class="main-col">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ipsum sapien, tincidunt ac augue sodales, consequat sodales elit. Nunc pharetra eget velit sed pharetra.
</section>
<aside class="aside-col">
<div class="pack">
Sed luctus nisl ut ipsum scelerisque semper. Nullam euismod eros vitae odio viverra tristique. Nam pulvinar massa at diam congue, vitae fringilla neque varius. In molestie quis neque luctus facilisis.
Vestibulum sit amet mi ut odio condimentum dictum vel a metus. Morbi ultrices enim ut accumsan lacinia. Praesent augue purus, bibendum in odio in, pharetra consectetur mi. Vivamus ac arcu dignissim, placerat ipsum eu, tempor magna. Integer nec ipsum dui. Quisque at diam est. Aliquam ut placerat ligula, eu venenatis turpis. Sed nec eros vel ante ornare eleifend. Suspendisse aliquam nulla consectetur tellus molestie efficitur.
</div>
</aside>
</div>
</div>
</div>
CSS
body{
font-family: arial;
font-size: 14px;
color: #333;
line-height: 1.5;
overflow-y: scroll;
margin:0;
padding: 0;
}
*, *::before, *::after {
box-sizing: border-box;
}
.container:after,
.cols-wrap:after,
.page-cols:after{
clear: both;
content: "";
display:table;
}
.container{
margin: 0 auto;
max-width: 1200px;
min-width: 300px;
padding:0 10px;
position: relative;
}
.page-cols{
background-color: #999;
}
.cols-wrap{
width: 100%;
position: relative;
background-color: #ccc; /*this can be #fff too to match body bg*/
box-shadow: 10px 10px 10px -10px #000;
right: 320px;
}
.cols-wrap .main-col{
float: left;
left: 320px;
position: relative;
width: 100%;
padding-right: 340px;
}
.cols-wrap .aside-col{
float: right;
position: relative;
width: 320px;
margin-right: -320px;
padding-left: 20px
}
In the follwing example the text goes out of the box. And when I reduce the size of the borowser the size of the boxes shring resposively but the text becomes mixed and unorganized. How can solve this?
<html>
<head>
<meta charset="utf-8">
<title>This is an email template</title>
<style>
body {
background-color: rgba(79, 183, 227, 0.4);
direction: rtl;
}
body * {
font-family: Tahoma;
}
a:link {
text-decoration: none;
margin-right: 25px;
color: #46B1F9;
}
#wrap {
background-color: #e0f2f6;
margin: auto;
width: 75%;
padding: 15px;
border: 1px solid grey;
}
.item {
border: 1px solid #95A5A6;
border-radius: 5px;
margin-bottom: 25px;
width: 60%;
display: inline-block;
}
.item p {
font-size: 1em;
}
.item img {
float: left;
width: 30%;
}
.item .notice {
text-align: center;
float: right;
padding-top: 25px;
padding-right: 25px;
width: 50%;
height: 1em;
}
/*clearfixes*/
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.clearfix {
display: inline-block;
}
/* Hides from IE-mac \*/
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
/* End hide from IE-mac */
</style>
</head>
<body>
<div id="wrap">
<div style="padding:15px;">
<div class="item clearfix">
<div class="notice">
<p><strong>Lorem ipsum</strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam rhoncus sollicitudin aliquet. Fusce dolor leo, egestas non nisi in, aliquam ullamcorper diam. Quisque placerat tortor in porta egestas. Aenean et elementum purus. Nunc eget nulla blandit, volutpat libero non, finibus purus. Vivamus vitae tellus at risus commodo varius.</p>
</div>
<img src="http://s14.postimg.org/wqzq39iht/image.jpg" alt="" />
</div>
<div class="item clearfix">
<div class="notice">
<p>
<strong>اLorem ipsum</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam rhoncus sollicitudin aliquet. Fusce dolor leo, egestas non nisi in, aliquam ullamcorper diam. Quisque placerat tortor in porta egestas. Aenean et elementum purus. Nunc eget nulla blandit, volutpat libero non, finibus purus. Vivamus vitae tellus at risus commodo varius.</p>
</div>
<img src="http://s10.postimg.org/y4kk17q21/image.jpg" alt="" />
</div>
<div class="item clearfix">
<div class="notice">
<p><strong>Lorem ipsum</strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam rhoncus sollicitudin aliquet. Fusce dolor leo, egestas non nisi in, aliquam ullamcorper diam. Quisque placerat tortor in porta egestas. Aenean et elementum purus. Nunc eget nulla blandit, volutpat libero non, finibus purus. Vivamus vitae tellus at risus commodo varius.</p>
</div>
<img src="http://s3.postimg.org/xca6ju1kj/image.jpg" alt="" />
</div>
</div>
</div>
</div>
</div>
</body>
</html>
If you are trying to expand the block by content, removing height from .item .notice should fix the issue.
In all cases your text will overflow the box , so you should add overflow:scroll to notice class
Depends on what you are trying to do.
If the boxes must be a fixed height there are couple of different strategies.
The easiest thing to do is to turn off the height restriction to the notice class. However, this will reflow your document and push everything down.
On the other hand, if you want to keep the current layout, I cannot provide you a unilateral decision as the padding, height and overflow will conflict with each other on this element.
The problem should be able to be seen live at this link (on every page, as the main content of the page is contained by my "content" div): http://tucsonbagley.com/index.html
The "content" class (a container div) has a much larger margin on the left than on the right and, after going over my CSS ad nauseum, I just cannot figure out why. I've broken something for sure (it was working not long ago!), but I just can't figure out what.
If I remove my id Navbar or id Header divs, the Content div will default back to the left... yeah, at this point I'm lost.
The CSS in question:
.content{
display:inline-block;
margin:0 auto;
width: 68%;
overflow:hidden;
text-align: center;
padding: 10px;
background-color: #FFFFFF;
font-size: 12px;
border-radius: 10px 10px 10px 10px;
}
Example HTML:
<body>
<div class="header">
<p>Tucson Bagley</p>
</div>
<div id="socialmedia">
<img src="images/Twitter_logo_blue.png"/>
<img src="images/linkedin.png"/>
<img src="images/facebook.png"/>
</div>
<div id="header">
<small>BagelHero#gmail.com</small>
</div>
<div id="navbar">
<ul>
<li><span>Gallery</span></li>
<li><span>Resume/CV</span></li>
<li><span>Contact me</span></li>
</ul>
</div>
<div class="content">
<div class="thumbleft"><h2>This is some content.</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non varius metus. Pellentesque eu nunc tortor. Aliquam id lectus orci. Sed id consectetur eros. Curabitur semper nisl nibh, rhoncus lacinia nibh volutpat at. Pellentesque sollicitudin vitae ipsum ut dictum. Proin ac risus ac nisi interdum hendrerit. Pellentesque sodales mauris ac eleifend vehicula. Nulla convallis aliquet urna varius auctor. Donec eget ipsum ut mauris consequat auctor eget sit amet odio. Nullam sed lorem erat. Praesent consequat porttitor magna, sit amet feugiat odio tincidunt ut. Fusce congue eros vel quam condimentum, vel consectetur quam imperdiet. </p>
</div>
</br>
<div id="copyright">
<p>Copyright 2012-2014 | Tucson Bagley</p>
</div>
</body>
Some help would be appreciated. Thanks in advance!
Add a <div style="clear:both"></div> before .content div and apply display:block to .content instead of display:inline-block and that's it
change the css of your .content to look like this
.content{
position: absolute;
left:0px;
right:0px;
display:inline-block;
margin:10px auto;
width: 68%;
overflow:hidden;
text-align: center;
padding: 10px;
background-color: #FFFFFF;
font-size: 12px;
border-radius: 10px 10px 10px 10px;
}
the magic is the left:0px combined with right:0px and margin:10px auto which will only work in absolute mode.
Edit - updated css as per comments.
I am trying to do something very simple. I want my text to stay contained within my <div>. I was having this problem earlier with two floating divs. I tried clearing them, and using word-wrap however that did not solve the problem. So I put that on hold then moved on to something new.
While creating another div that was not floating, I noticed once I placed the text inside the <p></p> tag, the text extended outside the div again. I know this because initially I forgot to place the text in the <p> tag, and the text stayed in the box. Once I corrected it, the text extended out again. Please help. I am pulling my hair out for what I know should be something simple.
Side Note: I do not want to use overflow:scroll;. I don't have enough text for that.
#topNews {
width: 625px;
height: 220px;
position: relative;
font-family: Arial Arial, Helvetica, sans-serif;
font-size: 14px;
border-bottom: solid #7e7d7d thin;
float: left;
margin-left: -30px;
margin-top: -15px;
}
#about {
width: 320px;
height: 180px;
position: relative;
margin-right: 3px;
margin-left: 3px;
margin-top: 7px;
border: dashed red thin;
}
<div id="topNews">
<div id="about">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse et turpis sed metus fermentum pellentesque. Vestibulum auctor neque ac nunc elementum malesuada. Praesent non est sed libero vestibulum consectetuer. Sed vehicula. Vivamus quis tellus sit amet erat ultrices luctus. Fusce a ligula. Fusce viverra libero vitae velit.
</p>
</div>
</div>
Its Gone out of div because
#topNews {
width: 625px;
height: 220px;
position: relative;
font-family: Arial Arial, Helvetica, sans-serif;
font-size: 14px;
border-bottom: solid #7e7d7d thin;
float: left;
margin-left: -30px;
margin-top: -15px;
}
In your code you specifies margin with -ve value. So its starting position may be in -ve x-axis.
Use +ve x-axis values...
like
margin-left: 0px;
margin-top: 0px;
Fiddle link
Text IS inside a div, its just the div is positioned out of you view because you used:
margin-left: -30px;
margin-top: -15px;
check out this image: click (i edited -30 and -15 to 0 and 0)
to make your job easier in future, use developer tools (f12 by default)
I just tried out your sample code and the text is contained in the DIV properly ..
I think this will helpful for you.
HTML
<div id="topNews">
<div id="about">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse et turpis sed metus fermentum pellentesque. Vestibulum auctor neque ac nunc elementum malesuada. Praesent non est sed libero vestibulum consectetuer. Sed vehicula. Vivamus quis tellus sit amet erat ultrices luctus. Fusce a ligula. Fusce viverra libero vitae velit.
</p>
</div>
<div id="about">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse et turpis sed metus fermentum pellentesque. Vestibulum auctor neque ac nunc elementum malesuada. Praesent non est sed libero vestibulum consectetuer. Sed vehicula. Vivamus quis tellus sit amet erat ultrices luctus. Fusce a ligula. Fusce viverra libero vitae velit.
</p>
</div>
</div>
CSS
#topNews{
width:625px;
height:220px;
position:relative;
font-family:Arial Arial, Helvetica, sans-serif;
font-size: 14px;
border-bottom:solid #7e7d7d thin;
}
#about{
width:200px;
float:left;
margin-right:3px;
margin-left:3px;
margin-top:7px;
padding:5px;
border: dashed red thin;
}
Perhaps you have css somewhere after that changes the size of your p tag. Also if you have anything with a width of 100% (ie: width: 100%;), it's always 100% plus the size of your margins/padding which would make elements stick out.