How do i align 3 elements with bootstrap 4 according to my designs? - css

I apply the rules of bootstrap but my buttons seems to go out of its alignment. my "Buy Now" and "View More" buttons should be place at the right side of the each sections. But i can seems to make it with bootstrap. I do not want to use Css to align it because i wanted it to be responsive. Can anyone enlighten me to help me out with my issues?
below here are my codes
<div class="container">
<div class="row" id="myDIV">
<?php
$sql = "SELECT * FROM products";
$query = $conn->query($sql);
if (!mysqli_num_rows($query)) {
echo '
<div class="col-12">
<div class="badge badge-danger">No Products Found</div>
</div>
';
} else {
while ($row = $query->fetch_assoc()) {
?>
<section id="product-display" style="z-index: 1;background: linear-gradient(180deg, <?php echo $row['product_section_colour']; ?> 25.52%, rgba(42, 86, 147, 0) 100%);">
<div class="container-fluid">
<div class="row">
<div class="col-2" style="top:-15px; left:-20px;">
<img style="height: 160px;width: 105px;left: -2px;top: -15px;border-radius: 0px;" loading="lazy" loading="lazy" id="product_img" src="images/product-main/<?php echo $row['product_photo']; ?>" alt="">
</div>
<div class="col-6 text-justify" style="position: absolute;height: 68px;left: 22%;right: 27.05%;">
<p style="color:<?php echo $row['product_dec_colour']; ?>;font-size:20px; padding-bottom:2px;font-weight: 600;"><?php echo $row['product_title']; ?></p>
<ul>
<li style="color:<?php echo $row['product_dec_colour']; ?>;font-size:7px;position: absolute;height: 68px;top: 35px;line-height: 8px;font-weight: 400;"><?php echo $row['product_desc']; ?></li>
</ul>
</div>
<div class="col-4">
Buy Now
View More
</div>
</div>
</div>
</section>
<?php
}
}
?>
</div>
this are my css
.buynow {
min-height: 32px;
background: #ffffff;
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25);
border-radius: 5px;
font-family: Inter;
font-style: normal;
font-weight: normal;
font-size: 12px;
line-height: 15px;
text-align: center;
width: 90px;
position: absolute;
top: 17px;
}
.viewmore {
min-height: 32px;
background: #ffffff;
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25);
border-radius: 5px;
font-family: Inter;
font-style: normal;
font-weight: normal;
font-size: 12px;
line-height: 15px;
text-align: center;
width: 90px;
position: absolute;
top: 58px;
}
section {
height: 107px;
width: 100%;
left: 0px;
top: 0px;
border-radius: 0px;
display: inline-block;
}
* {
padding: 0px;
margin: 0px;
}
ul li {
list-style-position: outside;
margin-left: 1em;
}

Why did you made "col-6" class as position:absolute? it will work if you remove that. you have used col-2,col-6,col-4 this is enough no need of position: absolute

I cannot run your code, but you can try with flex. Here is an example
<div class="d-flex">
<div class="col-4 mf-auto">
Buy Now
View More
</div>
</div>
You need to add mf-auto to your css file too.
This will help to align your content to the right side
.mf-auto {
margin-left: auto;
}

Related

Why borders are getting chopped in safari browser?

I am trying to achieve borders on each print page, on chrome it works fine but in safari border is getting chopped.
I have created a div which is fixed. That div has borders so when window print is triggered, borders comes on all the pages on chrome, but not on safari.
Anyone has solution for this??
my code:
<div class="loading-mask" data-role="loader" style="display: none !important">
<div class="loader">
</div>
</div>
<div class="cutom-container"></div>
<div class="content-div">
<div>
<div class="logo-content">
<div class="logo-div">
<img class="print-logo" src="<?= $this->getViewFileUrl('images/cart-page-print-logo.png'); ?>" alt="<?= __('Print Header Logo'); ?>"/>
<p>
----- </h3>
</p>
<div class="input-container">
<label>Company Name : </label><span id="pcname"> </span>
</div>
<div class="input-container">
<label>Contact : </label><span id="pcontact"> </span>
</div>
<div class="input-container">
<label>Phone : </label><span id="pphone"> </span>
</div>
</div>
</div>
<div class="img-content">
<img class="promotional-img" src="<?= $this->getViewFileUrl('images/PRT-offer graphic.png'); ?>" alt="<?= __('Print Offer'); ?>"/>
</div>
</div>
<div>
<div class="input-container">
<label>Email : </label><span id="pemail"> </span>
</div>
<div class="input-container">
<label>Delivery Address : </label><span id="daddress"> </span>
</div>
<div class="input-container">
<label>Mailing Address : </label><span id="maddress"> </span>
</div>
</div>
<div>
<table id="product-list-print">
</table>
</div>
<div id="sub-total-print">
</div>
<div>
<div class="logo-content">
<p>
Shipping (Shipping rates are appox and apply to US Mainland ONLY)</br> - Please see Sales Specialist for exact quote. Shipping rates for Aff ordable Advantage Trailers do not apply. Park Model Units will require additional shipping fee. <strong>Estimate is valid for 7 days.</strong>
</p>
</div>
<div class="img-content">
<div>
To order this unit sign here
</div>
<div>
<canvas id="myCanvas" style="width: 100%">Your browser does not support the HTML5 canvas tag.</canvas>
</div>
</div>
</div>
</div>
css :
/* Print page css */
.cutom-container{
border : solid #670827 5px;
border-radius: 10px;
position:fixed;
overflow: auto;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: none;
/*border: 5px solid red;*/
}
.content-div{
padding: 10px 5px 5px 5px;
display: none;
}
.logo-content{
display: inline-block;
width: 64%
}
.img-content{
display: inline-block;
width: 35%
}
.print-logo{
width: 50%;
}
.logo-div{
text-align: center;
}
.promotional-img{
width: 100%;
}
.img-content{
text-align: center;
}
.input-container{
padding: 8px;
text-align: left;
border:solid #670827 1px;
font-size: 15px;
margin: 10px;
}
/* end */
.warranty-container{
padding: 10px;
font-size: 16px;
border: solid;
border-width: 1px;
}
.cart-product-warrenty{
display: none;
}
.center-align{
text-align: center;
}
#signArea{
margin-bottom:20px ;
}
#media print {
#page {
border : solid #670827 5px;
border-radius: 10px; }
.cart-container{
display: none;
}
.cutom-container{
display: block !important;
padding: 15px;
}
.content-div{
display: block !important;
padding: 15px;
}
.cart-product-warrenty{
display: contents;
}
.summary.title{
display: none;
}
#sub-total-print>.fieldset{
display: none;
}
#block-shipping{
display: none;
}
input.qty{
width: 50px !important;
padding: 0 !important;
text-align: center;
}
.product-item-name{
text-decoration: unset;
font-size: 1.8rem;
line-height: 1;
font-weight: 700;
padding-top: 0px;
}
.messages{
display: none;
}
a{
text-decoration: none !important;
}
}
#media only screen and (max-width: 600px) {
.modal-content{
width: 80%;
}
.current{
width: 250px !important;
}
.sign-pad{
width: 247px !important;
}
.modal-content{
margin-bottom: 55px;
}
.cart-product-warrenty{
display: none;
}
}

Css fixed height content inner beetwen footer and header

First look at the picture:
Like you see my center of page i mean this content with form on small resolution get over the navbar. This content is centered verticaly and horizontal by flex.
here is code and what i try:
html`
<nav>
<div class='row header-inner'>
<div class='col-md-10 col-lg-10 col-lg-offset-2 col-md-offset-2 col-sm-offset-1 col-sm-11 col-xs-12'>
<div class='row logo-inner'>
<img src="assets\static\Logo.png">
</div>
<div class='row menu-inner'>
<a class='menu-item' routerLink="/aboutUs" routerLinkActive="active">about us</a>
<a class='menu-item' routerLink="/skiCams" routerLinkActive="active">skicams</a>
<a class='menu-item' routerLink="/contactUs" routerLinkActive="active">contact</a>
</div>
</div>
</div>
</nav>
<div class='row content-inner'>
<div class='col-md-8 col-lg-8 col-lg-offset-2 col-md-offset-2 col-sm-offset-1 col-sm-10 col-xs-12'>
<router-outlet></router-outlet>
</div>
</div>
<footer>
<div class='row center-block'>
<div class='col-md-offset-5 col-lg-offset-5 col-md-2 col-lg-2 col-sm-offset-5 col-sm-2 col-xs-offset-3 col-xs-6 footer-content'>
Powered by PGS
</div>
</div>
</footer>`
and css
footer {
border-top: 1px solid #40637e;
background-color: #282828;
position: fixed;
left: 0;
bottom: 0;
height: 110px;
width: 100%;
overflow:hidden;
}
.footer-content{
color :#959595;
border-top :1px solid #959595;
text-align: center;
margin-top:30px;
padding: 20px;
font-size: 10px;
}
.logo-inner{
margin: 35px 0px 35px 0px;
}
.header-inner{
border-bottom:1px solid #dbdbdb;
padding-bottom: 13px;
margin: 0;
}
.menu-inner{
margin:0px;
}
.menu-item{
margin-right: 40px;
padding-bottom: 15px;
font-size: 14px;
text-transform: uppercase;
font-weight: bold;
color:#545454;
}
.active{
border-bottom:1px solid #ef6716;
color: #ef6716;
}
a:hover, a:focus {
color: #ef6716;
text-decoration: none;
}
.content-inner{
background-color:#f8f8f8;
margin: 0;
/*margin-bottom:200px;*/
}
#media(max-width : 768px){
.menu-item{
margin-right:30px;
padding-bottom: 14px;
font-size: 14px;
text-transform: uppercase;
}
.menu-inner{
margin:0px;
text-align: center;
}
.logo-inner{
margin: 35px 0px 35px 0px;
text-align: center;
}
}
could you help my do something like this when the height is smaller the page start scrolling ?
It looks like you're missing your flexbox code in your question. Without seeing it all, I'd suggest trying to remove flexbox in the smaller breakpoints and just using display: block; and making sure your <div class='row content-inner'> element is statically positioned (position: static;).

2 images or divs next to eachother

I'm busy with my first attempt to responsive webdesign and i'm trying to put 2 images next to eachother. When I view the website on a desktop computer the page layout is just fine. But when i'm viewing it on a mobile (or I resize the window) the 2 images at the bottom are not inline anymore and jump on top of eachother.
Any idea how to solve this?
The page is on this test host: www.igga.nl.
Here's my markup:
#media screen and (max-width: 568px) {
#footer {
position: fixed;
left:0px;
bottom:0px;
height: 110px;
border-top: 7px solid #fff;
background-image: url('../images/bg_footer.png');
background-repeat: repeat;
width: 100%;
}
#pos {
width: 100%; /* parent */
}
#footer-info {
width: 100%;
float: left;
}
#centerpos {
width: 94%;
margin: 0 auto;
}
.tree {
float: left;
margin: 10px 1.76056338028169% 0 0;
width: 6.69014084507042%; /* 427 / 960 */
}
.logo-cont {
border-bottom: 0;
}
.logo {
margin-top: 18px;
width: 91.54929577464789%;
border-bottom: 1px solid #000;
padding-bottom: 2px;
}
.info-cont {
clear: both;
width: 100%;
margin: 2px 0 0 8.45070422535211%;
}
.info {
margin: 3px 0 0 0;
letter-spacing: 1px;
text-transform: uppercase;
color: #fff;
font-size: 0.875em;
}
.info a {
display: inline;
text-transform: lowercase;
text-decoration: none;
color: #000;
}
.info-telnr {
margin: 3px 0 0 0;
letter-spacing: 1px;
text-transform: uppercase;
color: #fff;
font-size: 0.875em;
}
.info-telnr h5 {
display: inline;
text-transform: lowercase;
text-decoration: none;
letter-spacing: 1px;
color: #000;
font-size: 1em;
}
}
and this is my HTML:
<div id="footer">
<div id="pos">
<div id="footer-info">
<div id="centerpos">
<img class="tree" src="sites/all/themes/md/images/logo_tree.png">
<div class="logo-cont">
<?php if ($logo): ?>
<a href="<?php print $front_page; ?>" title="<?php print t('MD | Illustration & Design'); ?>" rel="home" id="home">
<img class="logo" src="<?php print $logo; ?>" alt="<?php print t('MD | Illustration & Design'); ?>" />
</a>
<?php endif; ?>
</div>
<div class="info-cont">
<div class="info">
mail info#example.nl
</div>
<div class="info-telnr">
phone <h5>+31600000000</h5>
</div>
<div class="info">
shop www.thepossiblemachine.nl</p>
</div>
</div>
</div>
</div>
</div>
Try to set float:left for both divs/images. It helps in many cases but I can't tell if it will be useful in your problem without the code. It should look something like:
<div id="image1" style="float:left">
<img src="images/yourimage1" alt=""/>
</div>
<div id="image2" style="float:left">
<img src="images/yourimage2" alt=""/>
</div>
I hope this helps.

entire clickable <div> with nested divs

What I'm trying to do is to change the background color on the whole "row" div on mouse over and open the href link clicking on any part of the div. I have tried all the solutions I found on SO (both with jquery and pure css) but I can't get it working
Here is my code:
HTML
<div id="row">
<div class="document-date"><?php the_time('d-m-Y') ?></div>
<div class="document-category"><img src="/images/icon.png" /></div>
<div class="document-title">My link
<p>some description</p>
</div>
And the CSS
#row {
position: relative;
width: 700px;
padding: 5px 0 5px 10px;
display: block;
float: left;
}
#row:hover {
background: #fbf5d8;
}
.document-date{
float: left;
color: #1b6392;
font-size: 12px;
margin-right: 10px;
line-height: 35px;
}
.document-category{
float: left;
margin-right: 10px;
line-height: 35px;
}
.document-title {
width: 350px;
float: left;
color: #020100;
font-size: 12px;
font-weight: normal;
margin-top: 1px;
text-decoration: none;
}
.document-title a{
width: 350px;
float: left;
color: #020100;
font-size: 14px;
font-weight: bold;
margin-top: 1px;
text-decoration: none;
display: block;
width: 100%;
height: 100%;
}
.document-title a:hover{
color: #fff;
}
Any suggestion?
Assuming when you say li, you mean div#row
CSS:
#row:hover {
cursor: pointer
}
JavaScript (using jQuery):
$('#row').click(function() {
// do something
// example:
$(this).find('a:first').click();
});
<div id="row" onclick="alert(1)">
<div class="document-date" >12-08-2014</div>
<div class="document-category" ><img src="/images/icon.png" /></div>
<div class="document-title" ><a href="myurl..." target="_blank" >My link</a><br/><p>some description</p>
</div>​
This would do the trick.
Or if you want the divs separately
<div id="row">
<div class="document-date" onclick="alert(1)">12-08-2014</div>
<div class="document-category" onclick="alert(1)" ><img src="/images/icon.png" /></div>
<div class="document-title" onclick="alert(1)"><a href="myurl..." target="_blank" >My link</a><br/><p>some description</p>
</div>​

CSS - 3columns page

I am trying to do 3 columns page and I have problem.
My html:
<?php
$this->headMeta()
->setIndent(8)
->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8')
->appendName('keywords', 'story')
;
$this->headTitle()
->setIndent(8)
->setSeparator(' - ')
->headTitle('Your Story')
;
echo $this->doctype();
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<base href="<?php echo $this->baseUrl(); ?>" />
<link rel="stylesheet" type="text/css"
href="<?php echo $this->baseUrl('/styles/site.css'); ?>" />
<?php
echo "{$this->headMeta()}
{$this->headTitle()}
{$this->headLink()}"
?>
</head>
<body>
<div id="BODY">
<div id="HEADER">
<div id="headerLogin">
<div id="logged-in-as">
<?php echo $this->loggedInAs(); ?>
</div>
</div>
<div id="IMAGE">
<img src="../images/write.png" alt="" height="20%" width="90%" />
</div>
<div id="LOGO">
<img src="../images/logo.png" alt="Your true Story..." height="30%" width="160%"/>
</div>
<div id="USER">
</div>
</div>
<div id="MENU">Menu:
<div id="MENU_IN">
<div id="LIST">
<ul>
<?php
echo $this->menuLinks();
?>
</ul>
</div>
</div>
</div>
<div id="CONTENT">
<img src="../images/ScG.png" alt="" height="10%"/>
<div id="CONTENT_IN">
<?php echo $this->layout()->content ?>
<img src="../images/ScD.png" alt="" height="10%" />
</div>
</div>
<div id="INFORMATIONS">
<?php
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
?>
Your profile:
<div id="INFORMATIONS_IN"
<div id="LIST">
<ul>
<?php
echo $this->usersProfilLinks();
?>
</ul>
</div>
</div>
<?php } ?>
</div>
<div id="FOOT">Iwona Jamroz</div>
</div>
</body>
My CSS:
body
{
background-image: url(../images/back.png);
background-repeat: repeat;
padding-top: 10px;
padding-left: 10px;
padding-right: 10px;
overflow: visible;
height: 100%;
}
#IMAGE {
margin-top: 15px;
margin-left: 8%;
float: left;
}
#LOGO{
margin-top: 5px;
margin-right: 25%;
float: right;
}
#HEADER{
margin-bottom: 15%;
}
#MENU {
width: 20%;
height: 10%;
background-image: url(../images/texMenuBack.png);
margin-right: 5px;
float: left;
}
#MENU_IN
{
margin-top:10%;
height: 10%;
margin-bottom: 5px;
margin-left: 5px;
margin-right: 5px;
background-image: url(../images/texMenuMid.png);
}
#CONTENT{
margin-left: 21%;
margin-right: 21%;
float: left;
}
#CONTENT_IN {
padding-left: 8px;
padding-right: 5px;
padding-top: 5px;
padding-bottom: 5px;
background-image: url(../images/texM.png);
background-repeat: repeat;
min-height: 150px;
}
#INFORMATIONS {
width: 18%;
background-image: url(../images/texMenuBack.png);
margin-left: 5px;
float: right;
}
#INFORMATIONS_IN{
margin-top: 14%;
margin-bottom: 4px;
margin-left: 3px;
margin-right: 3px;
background-image: url(../images/texMenuMid.png);
}
#FOOT {
clear: both;
vertical-align: middle;
}
#headerLogin a{ color: white;
text-align: left;
word-spacing: 3px;
font-family: fantasy;
font-size: 24px;
}
#headerLogin {
color: whitesmoke;
font-family: monospace;
font-size: 24px;
}
#LIST {
}
And I have 3 columns but one after another and I can not understand it as I have read that to do 3 columns layout is enought to write in CSS float: left, float: left, float: right but I all the time have one after another not in one row :/ Why?
It looks like this:
aaa
.......aaaaaa
...................aaa
Floats are tricky and you should try to test it with different browsers. However, I did notice this
#CONTENT{
margin-left: 21%;
margin-right: 21%;
float: left;
}
Try to remove the margin-left and margin-right, because it probably causes the effect you are describing.
Try this instead:
#CONTENT{
width: 20%;
float: left;
}
I would consider using a CSS Framework such as 960 or Blueprint CSS, it will make columned layouts incredibly easy and cross-browser compliant. With CSS frameworks there is no need to write layout CSS, eliminating a great deal of browser compatibility testing and it helps keep your presentational CSS clean and tidy.
Your html will end up looking something like this (example is in 960)
<div class="container_24">
<div class="grid_8"></div>
<div class="grid_8"></div>
<div class="grid_8"></div>
</div>
Explanation: A 24 column container, where each column is 8 columns wide, will result in a 3 column layout.

Resources