What is the best way to align bootstrap div horizontally? - css

I've tried col-centered class, margin:0 auto, but I need to see the width of the containing div to a set pixel width...I don't want that....has to be responsive also.
The pen is here:
http://codepen.io/Satearn/pen/WpzJYy
.center-portfolio
{
margin:0 auto;
padding-left:20px;
width:800px;
}

In this case you could add text-align: center; to .center-portfolio and add .center-portfolio > p { display: inline-block;}. But you would have to add additional margin-top to .center-portfolio
View on Codepen
You can check https://css-tricks.com/centering-css-complete-guide/ for more info on centering things in CSS, very cool article.
P.S. You might want to change the width to max-width

APPLY THE CSS
.glyphicon.glyphicon-print ,
.glyphicon.glyphicon-globe ,
.glyphicon.glyphicon-tag ,
.glyphicon.glyphicon-plus-sign ,
.glyphicon.glyphicon-tint
{
font-size: 5vw;
color:#88BA00;
}
.center-portfolio
{
margin:0 auto;
display:block;
padding-left:20px;
text-align:center;
}
p
{
display:inline-block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="center-portfolio">
<p><span class="glyphicon glyphicon-print portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-tag portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-plus-sign portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-globe portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-tint portfolio_categories"> </span>
</p>
</div>

Try This HTML5 markup for Bootstrap based coding
.glyphicon.glyphicon-print,
.glyphicon.glyphicon-globe,
.glyphicon.glyphicon-tag,
.glyphicon.glyphicon-plus-sign,
.glyphicon.glyphicon-tint {
font-size: 5vw;
float: left;
color: #88BA00;
}
.center-portfolio {
margin: 0 auto;
padding-left: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="center-portfolio">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<p><span class="glyphicon glyphicon-print portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-tag portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-plus-sign portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-globe portfolio_categories"> </span>
</p>
<p><span class="glyphicon glyphicon-tint portfolio_categories"> </span>
</p>
</div>
</div>
</div>
</div>

Related

I use image and text side by side in footer but it creates problem when window is resized

Image after resize:
I use this code in my footer section. I have an image and some content side by side using media object class in bootstrap 4, but when the window is resized, the image and the content do not remain same and it creates a problem.
Here is my code:
<div class="col-lg-3 col-md-3 col-sm-6 mt-5">
<h5>Product</h5>
<div class="media">
<div class="media-left">
<a href="#"><img class="media-object"
src="./assets/Img/prod.png" alt="..."></a>
</div>
<div class="media-body">
<h6>vulputate velit consequat. </h6>
<div class="text-primary">
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
<i class="far fa-star"></i>
</div>
<span><s>Rs1200.00</s> Rs1000.00 </span>
</div>
</div>
</div>
Image I actually want:
Would you mind using only CSS instead of using Bootstrap? If no, then you may check out this answer. I have written the code in pure HTML and CSS:
.container {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: #2F2F2F;
font-family: Arial;
color: white;
}
.img1 {
width: 20%;
padding-left: 10px;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<title>Title of the page</title>
</head>
<body>
<div class="container">
<h2 style="padding: 10px;">Product</h2>
<img src="https://camo.githubusercontent.com/09e55b5e6a65a3ba9e38ed4de0f96ddd8ad46ba5c57b3e94d05222e0f127402a/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f323037383234352f3235393331332f35653833313336322d386362612d313165322d383435332d6536626439353663383961342e706e67"
class="img1">
<p>vulputate velit consequat</p>
<h3>⭐⭐⭐⭐⭐</h3>
<span><s>Rs 1200</s> Rs 1000</span>
</div>
</body>
</html>

Button Class Get not the full length of div?

I have tried to give the full length of div . But button could not get the full length . Please help me to fix out the errors.
<div class="col-md-3 col-sm-6 text-center card">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
<span class="icon">
<img src="{{ URL::asset('frontAssets/assets/images/classroutine1.png')}}"
alt="Classroutine" style="width:50%;
height: 93.3px; padding-top: 15px; padding-bottom: 25px">
</span>
<div style=" padding-bottom: 10px; padding-top: 20px">
<h3>Class <br> Routine</h3>
</div>
</button>
</div>
Try to update css:
.card {
padding-right: 0px;
padding-left: 0px;
}
.block {
display: block;
width: 100%;
}
And the button has already taken full width of parent div, if you want to make div wider, try to adjust bootstrap column size, for example col-md-3 to col-md-6:
<div class="col-md-6 col-sm-6 text-center card">
Because in bootstrap, the column have padding-right: 15px; and padding-left: 15px; by default. So if you want your button to get the full width of the column, you can overwrite these css or add the css below to your button:
Demo:
.block {
margin-right: -15px;
margin-left: -15px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="col-md-3 col-sm-6 text-center card">
<button type="button" class="block" data-toggle="modal" data-target="#myModal">
<span class="icon">
<img src="{{ URL::asset('frontAssets/assets/images/classroutine1.png')}}"
alt="Classroutine" style="width:50%;
height: 93.3px; padding-top: 15px; padding-bottom: 25px">
</span>
<div style=" padding-bottom: 10px; padding-top: 20px">
<h3>Class <br> Routine</h3>
</div>
</button>
</div>
Use display: inline-block in both "span" and next "div" tag.
Remove padding to the column div:
.card{ padding:0px}
Here is the snippet:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<style>
.card{ padding:0px}
</style>
</head>
<body>
<script src="script.js"></script>
<div class="col-md-3 col-sm-6 text-center card">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
<span class="icon">
<!-- <img src="{{ URL::asset('frontAssets/assets/images/classroutine1.png')}}"
alt="Classroutine" style="width:50%;
height: 93.3px; padding-top: 15px; padding-bottom: 25px"> -->
</span>
<div style=" padding-bottom: 10px; padding-top: 20px">
<h3>Class <br> Routine</h3>
</div>
</button>
</div>
</body>
</html>
All Bootstrap columns (.col-*) have padding-x (padding-right: 15px; and padding-left: 15px;) by default.
If the button is the only child element of that column, and you don't want to override the class's styles, you can use the px-0 or p-0 class on the column to override the padding of only that column:
<div class="col-md-3 col-sm-6 text-center card px-0">
...
</div>
<div class="col-md-3 col-sm-6 text-center card">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" style="width:100%">
<span class="icon">
<img src="{{ URL::asset('frontAssets/assets/images/classroutine1.png')}}"
alt="Classroutine" style="width:50%;
height: 93.3px; padding-top: 15px; padding-bottom: 25px">
</span>
<div style=" padding-bottom: 10px; padding-top: 20px">
<h3>Class <br> Routine</h3>
</div>
</button>
</div>
Use width:100% as style or add it in any class and then apply that class to the button
Just use padding zero .
<div class="col-md-3 col-sm-6 text-center card px-0" style="padding: 0px ">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#classRoutine" style="width:100%">
<span class="icon">
<img src="{{ URL::asset('frontAssets/assets/images/classroutine1.png')}}"
alt="Classroutine" style="width:50%;
height: 93.3px; padding-top: 15px; padding-bottom: 25px">
</span>
<div style=" padding-bottom: 10px; padding-top: 20px">
<h3>Class <br> Routine</h3>
</div>
</button>
</div>

how to make icons stick with their texts?

I'm trying to build a responsive upper-headeras you see in this screenshot.
The problem as you see the message icon stay hanged while its text goes
down whenever the width between 757 and 575.
I'm still new in css in general and bootstrap 4.
Thank you in Advance!
.upper-bar {
font-family: Times;
background-color: #007872;
color: #fff;
}
.upper-bar a {
color: #fff;
}
.upper-bar-left,
.upper-bar-right {
margin: 15px 0;
text-align: center;
padding-left: 0;
}
#media (max-width: 575.98px) {
.upper-bar-left:first-child,
.upper-bar-right:first-child {
margin-bottom: 0;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<div class="upper-bar">
<div class="container">
<div class="row">
<div class="col-sm upper-bar-left text-sm-left">
<i class="fa fa-phone"></i> 00000009890
<i class="far fa-envelope"></i> lorem_ipsuml#xxxxx.xx
</div>
<div class="col-sm upper-bar-right text-sm-right">
<i class="fas fa-map-marker"></i> LOrem Ipsum 0, 00098 Loremipsum
</div>
</div>
</div>
</div>
Codepen: https://codepen.io/anon/pen/bxREoK?editors=1100
Keep the envelope icon and email anchor in a span with text-nowrap class on it
<span class="text-nowrap">
<i class="far fa-envelope"></i>
lorem_ipsuml#xxxxx.xx
</span>
See this for information on text-nowrap
.upper-bar {
font-family: Times;
background-color: #007872;
color: #fff;
}
.upper-bar a {
color: #fff;
}
.upper-bar-left,
.upper-bar-right {
margin: 15px 0;
text-align: center;
padding-left: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://use.fontawesome.com/2972279885.js"></script>
<div class="upper-bar">
<div class="container">
<div class="row">
<div class="col-sm upper-bar-left text-sm-left">
<i class="fa fa-phone"></i> 0542 1421455
<span class="text-nowrap">
<i class="fa fa-envelope"></i>
lorem_ipsuml#xxxxx.xx
</span>
</div>
<div class="col-sm upper-bar-right text-sm-right">
<i class="fas fa-map-marker"></i> LOrem Ipsum 0, 00098 Loremipsum
</div>
</div>
</div>
</div>
I suggest you can do like this:
html
<div class="icon-text">
<i class="fab fa-facebook-f">
<p> Your text</p>
</div>
css
.icon-text {
display: inline-block;
margin-right: 20px;
}
Please try this way.
CSS Code:
.left-style{
float:left;
}
HTML Code:
<div class="col-sm upper-bar-left text-sm-left">
<span class="left-style"><i class="fa fa-phone"></i> 00000009890</span>
<span class="left-style"><i class="far fa-envelope"></i>
lorem_ipsuml#xxxxx.xx</span>
</div>

CSS media queries kicking in without specified width

I have one media query that kicks in without the width specified as a condition being met, even at 375px the media query takes over from the base CSS. The media query should take over from 660px. Here is my index.html page:
<!DOCTYPE html>
<html>
<head>
<title>Thames Accountants</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="header-bg">
<header>
<button id="toggleButton" class="c-hamburger c-hamburger--rot">
<span>toggle menu</span>
</button>
<h1 class="logo">Thames Accountants</h1>
</header>
<p class="clear"></p>
<div class="ta-menu">
<nav>
<ul>
<li>Our Services</li>
<li>About Us</li>
<li>Blog</li>
<li>Contact Us</li>
</ul>
</nav>
</div> <!-- end ta-menu div -->
<div class="intro">
<p>Personalised Accounting</p>
<button type="button" class="btn btn-info ta-button">Get In Touch</button>
<div><span class="glyphicon glyphicon-chevron-down ta-icon"></span></div>
</div>
</div> <!-- end header-bg div -->
<div class="container">
<a name="services"></a>
<div id="services" class="services">
<h2 class="services-title">Accountancy Services</h2>
<p class="bullet-points">Annual Accounts <span class="glyphicon glyphicon-ok"></span></p>
<p class="bullet-points">Book-Keeping <span class="glyphicon glyphicon-ok"></p>
<p class="bullet-points">Company Secretarial <span class="glyphicon glyphicon-ok"></p>
<p class="bullet-points">Management Accounts <span class="glyphicon glyphicon-ok"></p>
</div>
<div class="services">
<h2 class="services-title">Added Value Services</h2>
<p class="bullet-points">Business Valuations <span class="glyphicon glyphicon-ok"></span></p>
<p class="bullet-points">Business Plans <span class="glyphicon glyphicon-ok"></p>
<p class="bullet-points">Management Systems <span class="glyphicon glyphicon-ok"></p>
<p class="bullet-points">Strategic Planning <span class="glyphicon glyphicon-ok"></p>
</div>
<div class="services">
<h2 class="services-title">Start-up Services</h2>
<p class="bullet-points">Ready made company <span class="glyphicon glyphicon-ok"></span></p>
<p class="bullet-points">Limited Liability Partnership <span class="glyphicon glyphicon-ok"></p>
<p class="bullet-points">PLC formation <span class="glyphicon glyphicon-ok"></p>
</div>
<div class="services">
<h2 class="services-title">Taxation Services</h2>
<p class="bullet-points">Contractors and IR35 <span class="glyphicon glyphicon-ok"></span></p>
<p class="bullet-points">Payroll, PAYE Returns and RTI <span class="glyphicon glyphicon-ok"></p>
<p class="bullet-points">VAT <span class="glyphicon glyphicon-ok"></p>
</div> <!-- end services div -->
</div> <!-- end container div -->
<div class="testimonials">
<h1 class="testimonial-title">Testimonials</h1>
<div class="ta-container">
<blockquote><p class="ta-review">Thames Accountants changes lives. Thanks for NOT being another overpaid below average bookkeeper but a true personalised accounting department for our company. - S. Johnson</p></blockquote>
<blockquote><p class="ta-review">Thames Accountants changes lives. Thanks for NOT being another overpaid below average bookkeeper but a true personalised accounting department for our company. - S. Johnson</p></blockquote>
<blockquote><p class="ta-review">Thames Accountants changes lives. Thanks for NOT being another overpaid below average bookkeeper but a true personalised accounting department for our company. - S. Johnson</p></blockquote>
</div>
</div>
<footer>
<div class="row ta-row">
<div class="col-md-4 ta-about">
<h4>About TA</h4>
<p>We are an experienced accounting agency based in South East, London, UK. We work closely with our clients and act for a broad range of business and personal clients.</p>
</div>
<div class="col-md-4 ta-social">
<h4>Social</h4>
<i class="fa fa-twitter"></i>
<i class="fa fa-facebook"></i>
<i class="fa fa-google-plus"></i>
<i class="fa fa-linkedin"></i>
</div>
<div class="col-md-4 ta-pages">
<h4>Menu</h4>
<ul>
<li>Our Services</li>
<li>About Us</li>
<li>Blog</li>
<li>Contact Us</li>
</ul>
</div>
</div> <!-- end row div -->
<div class="row ta-policies">
<div class="ta-center">
<div class="col-md-12">
<ul>
<li>Privacy Policy</li>
<li>Site terms</li>
</ul>
</div>
</div>
</div>
</footer>
<script type="text/javascript" src="js/app.js"></script>
</body>
</html>
And this is my CSS media query
Media queries for wider screens
**********************************/
#media (min-width: 660px) {
/*Parallax image for home page*/
.header-bg {
background: radial-gradient(#252625, transparent 150%), url('./img/tower-bridge.jpg');
background-attachment: fixed;
background-size: cover;
background-position: center center;
height: 600px;
width: 100%;
}
.logo {
font-size: 2em;
margin: 3% 0 0 5%;
text-align: left;
}
.intro p {
font-size: 1.5em;
margin-top: 10%;
}
.ta-button {
font-size: 0.6em;
padding: 5px;
border-radius: 5px;
}
.services-title {
font-size: 1.5em;
}
.ta-menu {
font-size: 1.5em;
}
.testimonial-title {
font-size: 1.75em;
}
blockquote {
font-size: 1.2em;
border-left: 3px solid #fff;
}
.services p {
font-size: 1em;
}
.ta-icon {
margin-top: 0;
}
.c-hamburger {
display: none;
}
.intro p {
margin-top: 0;
font-size: 1.2em;
border: none;
}
}/*End media query # 460 px*/

I have an accordian short code, but can not make it RTL

In the theme that I use, there is a shortcode making googd accordians. I am making the site RTL. Accordian's title and content have been RTL. But the plus sign (the square) does not follow the CSS rules added. I was wondering if anyone could help me make the plus sign RTL.
Page URL: http://sciself.com/?page_id=4766
HTML code is as follows,
<div id="text-13" class="widget widget_text">
<div class="textwidget">
<div class="accordian">
<h5 class="toggle">
<a href="#">
<span class="arrow">
</span>
title
</a>
</h5>
<div class="toggle-content " style="display: none;">
text
</div>
<h5 class="toggle">
<a href="#">
<span class="arrow">
</span>
title
</a>
</h5>
<div class="toggle-content " style="display: none;">
text
</div>
<h5 class="toggle">
<a href="#">
<span class="arrow">
</span>
title
</a>
</h5>
<div class="toggle-content " style="display: none;">
text
</div>
</div>
</div>
</div>
and CSS rules added are,
#text-13 .textwidget .accordian .toggle-content {
font-family: bkoodak !important;
direction: rtl !important;
text-align: justify !important;
}
#text-13 .textwidget .accordian h5.toggle a {
font-family: bkoodak !important;
direction: rtl !important;
float: right !important;
}
in the .arrow class in the line "2073" in your style.css add property like so:
h5.toggle span.arrow {
float:right;
direction:rtl;
margin-right:0;
margin-left:17px;
}
also your form need to be rtl, in the .gform_fields class add this property:
.gform_fields{
direction:rtl;
text-align:right;
}
موفق باشید :)
Try this:
h5.toggle span.arrow {
float:right;
direction:rtl;
margin-left:10px;
font-family:bkoodak;
}

Resources