Making whole "col-*" a link - html

Here's my HTML:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-sm-3">
<img class="img-sm" src="<?php echo Config::get('links/app_root') . 'assets/imgs/icons/user-add.png'; ?>">
<p>User Add</p>
</div>
<div class="col-sm-3">
<img class="img-sm" src="<?php echo Config::get('links/app_root') . 'assets/imgs/icons/user-edit.png'; ?>">
<p>User Edit</p>
</div>
<div class="col-sm-3">
<img class="img-sm" src="<?php echo Config::get('links/app_root') . 'assets/imgs/icons/user-delete.png'; ?>">
<p>User Delete</p>
</div>
</div>
</div>
I'm looking to make the HTML like this:
<a href="#">
<div class="col-sm-3">
....
</div>
</a>
Where when the whole column is a link and when hovered over it changes opacity and is able to redirect to another page. However when i change my HTML my style sheet gets super messed up, and the alignment goes all haywire. (See second Code Pen)
https://codepen.io/JDSWebService/pen/BZpoaq
This is how I want it to look when all is said in done. Three evenly spaced column's with the correct widths.
Heres the Codepen of the issues i'm running into when i change my HTML code
https://codepen.io/JDSWebService/pen/bRgVVz
Help?

You can add 'onclick' instead of messing around with tag since that will screw up the bootstrap's col settings.
For example, <div class="col-sm-3" onclick="location.href='add.user.php';">
Please check out this Codepen. I was not able to test your links, but please let me know if this is what you are looking for.
https://codepen.io/pkshreeman/pen/awpvGy

You can put the a tag inside the col-3 and put all the rest of the content in it. Display the a tag as block, then move the padding code that is on the col-3 to the a tag. You can also move the background and border radius to be on the a tag as well. The col-3 should just be that, columns.
.row {
display: flex;
justify-content: center;
}
.col-sm-3 {
text-align: center;
margin: 0 2.5%;
}
.col-sm-3:hover {
opacity: 0.9;
}
.col-sm-3 a {
font-size: 1.5em;
color: white;
display:block;
padding: 2.5% 25px;
background: #303030;
border-radius: 25px;
}
.col-sm-3 a:hover {
text-decoration: none;
color: #00bc8c;
}
.img-sm {
width: 100px;
height: 100px;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-sm-3"><a href="adduser.php">
<img class="img-sm" src="<?php echo Config::get('links/app_root') . 'assets/imgs/icons/user-add.png'; ?>">
<p>User Add</p></a>
</div>
<div class="col-sm-3"><a href="edituser.php">
<img class="img-sm" src="<?php echo Config::get('links/app_root') . 'assets/imgs/icons/user-edit.png'; ?>">
<p>User Edit</p></a>
</div>
<div class="col-sm-3"><a href="deleteuser.php">
<img class="img-sm" src="<?php echo Config::get('links/app_root') . 'assets/imgs/icons/user-delete.png'; ?>">
<p>User Delete</p></a>
</div>
</div>
</div>

I havn't tried this out but I'm pretty sure that one way is to give your link a class like:
<div class="container">
<div class="row">
<a href="adduser.php" class="link">
<div class="col-sm-3">
<img class="img-sm" src="<?php echo Config::get('links/app_root') . 'assets/imgs/icons/user-add.png'; ?>">
<p>User Add</p>
</div>
</a>
and then something like:
.link {
height: 100%;
width: 100%
}
of course from there you can give the .link whatever properties you like. Might not be the best solution, but it is one solution I believe.

This can be easily done with jquery
give class name other than col-sm-3 for each div
make firstcol or col-sm-3 for all cursor: pointer;
$(".firstcol").click(function(){
window.location = "URL";
});

Related

How do I change the width of my image in my theme Bludit?

I am working on a new CMS called bludit. I have chosen a theme for this cms but I still have to modify it a bit. Right now, I’m trying to make the image take the full width of the screen : Visuel site
Here you can see the code for the original header image :
<section class="page">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="content-card">
<!-- Page cover image -->
<?php if ($page->coverImage()): ?>
<div class="page-cover-image mb-4"
style="background-image: url('<?php echo $page->coverImage(); ?>');">
<div style="height: 400px;"></div>
</div>
<?php endif ?>
As I try to make the image take all the width but that the text below keeps these dimensions, I logically tried to get the div out of the image of the container as well as this col-lg-8. Here’s what I tried:
<div class="container-fluid">
<div class="row">
<!-- for the image take all the width -->
<div class="containerImage col-lg-12">
<div class="header-image">
<div class="contenu">
<!-- Page cover image -->
<?php if ($page->coverImage()): ?>
<div class="page-cover-image mb-4"
style="background-image: url('<?php echo $page->coverImage(); ?>');">
<div style="height: 400px;"></div>
</div>
<?php endif ?>
</div>
</div>
</div>
</div>
</div>
And the CSS :
.page-cover-image {
width: 100%;
}
.contenu {
width: 100%;
}
But I don’t understand why there is no effect... Anyone has an idea of the problem? Maybe an left margin specific to CMS? Probably I made a mistake...
Thank you very much in advance.
Sofia R.
The image has already a width of 100%. It's part of different div defining the width.
If you would like to have a greater width, you have to modify the theme, which uses Bootstrap.

fixed hidden footer showing though background

this is my first post here.
I've got a small problem with the website I'm working on at the moment.
Since I'm using a (css) parallax header I wanted to have a "special" footer as well.
The idea was to make it fixed to the bottom and let the body reveal the footer bottom first.
The problem is that my website is made up of multiple segments and the footer is visible in between them.
I tried to fix this by creating a background between the segments like this
.background {
color: #f1f1f1;
width: 100%;
height: 90%;
z-index: -2;
}
my footer looks like this
.footer {
padding: 40px 0;
text-align: center;
text-decoration: none;
background: black;
color: #white;
position: fixed;
bottom: 0;
width: 100%;
z-index: -1;
}
but whichever z-index I try, the footer is either completely in the background or in front of everything.
I don't really know what else I could try.
Here's my (shortend) HTML body (there's only the header and a navbar before that):
<div class="main">
<div class="row">
<div class="leftcolumn">
<div class="card">
<h1><?php echo $welcome1;?></h1>
<h5><?php echo $post;?></h5>
<p><?php echo $welcome2;?></p>
</div>
<div class="card">
<h2>Hiragana</h2>
<h5><?php echo $post;?></h5>
<img src="..//nihongo/pics/hiragana.png" width="650px" height="400px">
<p><?php echo $hira;?></p>
</div>
<div class="card">
<h2>Katakana</h2>
<h5><?php echo $post;?></h5>
<img src="..//nihongo/pics/katakana.png" width="650px" height="400px">
<p><?php echo $kata;?></p>
</div>
</div>
<div class="rightcolumn">
<?php include '../nihongo/php/language.php'; ?>
<div class="card">
<h2><?php echo $me1;?></h2>
<img src="../nihongo/pics/me.png" width="240px" height="322px" style="border: 1px solid black;border-radius:10px;">
<p><?php echo $me2;?></p>
</div>
<div class="card">
<h3><?php echo $use;?></h3>
<div class="fakeimg"><p>Hiragana</p></div><br/>
<div class="fakeimg"><p>Katakana</p></div><br/>
<div class="fakeimg"><p>Kanji</p></div><br/>
</div>
<?php include '../nihongo/php/follow.php';?>
</div>
</div>
</div>
<?php include '../nihongo/php/footer.php';?>
</body>
I'm using all those PHP variables because I'm running this website in multiple languages.
here is a screenshot of the issue without my "fix":
I can provide you more of my code if you want - just tell me what you want to see (I don't want to make this post too long right now).
You could define a white (?) background for .main and add a margin-bottom to .main whose value equals the height of the footer. That way the footer would only become visible after .main is scolled down all the way, in the space that is defined as its margin-bottom.

exclude div from parent style

I'm trying to override the .container class in bootstrap. I'm using Drupal 7 and I have a css file for my theme which is working perfectly until I want to override the .container
my HTML
<div class="main-container <?php print $container_class; ?>">
<div class="top-div" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
that PHP code will insert the class .container
I need to give the div with class .top-diva 100% size without any padding from the .container I've tried the child > selector and descendant selector and the :not(.top-div) methods nothing works. When I use the :not(.top-div) it applies changes on each and every page and element on the website AND the div which contains the .top-div which is really weird. Suggestions?
In bootstrap, the padding is applied on the container, not the inner divs. To override this on one element you need to give it negative horizontal margins.
Something like:
.container .top-div {
margin-left:-10px;
margin-right:-10px;
}
Where 10px should be replaced by the padding on .main-container.
If this doesn't work right away you may need greater specificity
Bootstrap's built-in .row class uses this method
Why don't you try:
.main-container {
position:relative;
}
.top-div {
position:absolute;
left:0;
top:0;
}
<div class="main-container <?php print $container_class; ?>">
<div class="top-div" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
If you are using bootstrap css than you don't need to give any custom css
You try to just add row class in your top-div class
it's a in built in bootstrap.css So no need for any extra custom css.
.row {
margin-left: -10px;
margin-right: -10px;
}
Example
<div class="main-container <?php print $container_class; ?>">
<div class="top-div row" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="main-container <?php print $container_class; ?>">
<div class="top-div row" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
Hope this will helps you.

Is it possible to set a background in a bootstrap column that oversizes the div? [duplicate]

This question already has answers here:
Extend bootstrap row outside the container
(7 answers)
Closed 5 years ago.
I need to code the next example:
I'm coding all website using bootstrap and the code of this section is this:
`<div class="bg_blue">
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-6">
<div id="login-form-box" class="form-box">
<div id="login-form-info" class="form-info">
<?php if (isset($content['info']) && !empty($content['info'])) {
echo $content['info'];
}
?>
</div>
<?php if (isset($error_message)) {
echo '<div id="login-form-info" class="form-error">'.$error_message.'</div>';
}
?>
<form id="login-form" class="form" action="<?php echo api_get_path(WEB_PATH)?>index.php" method="post">
<div>
<label for="login"><?php echo custompages_get_lang('User');?></label>
<input name="login" type="text" /><br />
<label for="password"><?php echo custompages_get_lang('Password');?></label>
<input name="password" type="password" /><br />
</div>
</form>
<div id="login-form-submit" class="form-submit" onclick="document.forms['login-form'].submit();">
<span><?php echo custompages_get_lang('LoginEnter');?></span>
</div> <!-- #form-submit -->
<div id="links">
<?php if (api_get_setting('allow_registration') === 'true') { ?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/inscription.php?language=<?php echo api_get_interface_language(); ?>">
<?php echo custompages_get_lang('Registration')?>
</a><br />
<?php } ?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>auth/lostPassword.php?language=<?php echo api_get_interface_language(); ?>">
<?php echo custompages_get_lang('LostPassword')?>
</a>
</div>
</div>
</div>
<div class="col-md-6">
<!-- <img class="img" src="<?php echo api_get_path(WEB_PATH)?>/custompages/images/bgimage.png" alt="Background" /> -->
</div>
</div> <!-- /row -->
</div><!-- /container -->
</div>`
The problem is that I cant set the image background to the second column that resizes and that covers the full with out of the column-md-6 to the right.
Here's a little sketch:
Updated 2018
Bootstrap 4, the concept is still the same: https://codeply.com/go/ffaQgse2SU
I have answered similar questions on this, but yours is a little different because the background-image. The best way I've found is using a CSS pseudo element becuase it adjusts along with right col-md-6 and therefore works responsively.
Bootstrap 3 Demo: http://codeply.com/go/rWOGi4LrU1
.right {
z-index: 0;
color: #fff;
}
.right:before {
background-image:url(..);
content: '';
display: block;
position: absolute;
z-index: -1;
width: 999em;
/* allow for bootstrap column padding */
top: -15px;
left: -15px;
bottom: -15px;
}
Demo
Also see:
Get Two Columns with different background colours that extend to screen edge
If you would like to target only medium screen sizes you can do it in the following way. give width: 120% to your img element and it will overflow and take the full size at the left.
working snippet
.img {
width: 120%;
}
.col-md-6 {
background-color: green;
}
<html>
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="bg_blue">
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-6">
<div id="login-form-box" class="form-box">
<div id="login-form-info" class="form-info">
</div>
<form id="login-form" class="form" action="" method="post">
<div>
<label for="login"></label>
<input name="login" type="text" /><br />
<label for="password"></label>
<input name="password" type="password" /><br />
</div>
</form>
<div id="login-form-submit" class="form-submit" onclick="document.forms['login-form'].submit();">
<span></span>
</div>
<!-- #form-submit -->
<div id="links">
<a href="">
</a><br />
<a href="">
</a>
</div>
</div>
</div>
<div class="col-md-6">
<img class="img" src="https://www.w3schools.com/css/trolltunga.jpg" alt="Background" />
</div>
</div>
<!-- /row -->
</div>
<!-- /container -->
</div>
</body>
</html>
NOTE:
If you want to target all screen sizes media then just use col-lg-* col-xs-* col-sm-* i.e different responsive bootstrap classes.
Hope this helps!
I finally did it by removing the "container" div.
Now I got a big problem in mobile, that the background image is lost on mobile.
http://www.thalescampusvirtual.com/index.php

How can I make pictures at the same height?

I have this site:
link
CODE HTML:
<div class="grid-sizer"></div>
<!-- # ROW-1 # -->
<div class="row">
<div class="grid-item item-1" >
<img src="<?php echo ot_get_option('left1_img'); ?>" />
</div>
<div class="grid-item item-2">
<img src="<?php echo ot_get_option('center1_img'); ?>" />
</div>
<div class="grid-item item-3">
<img src="<?php echo ot_get_option('right1_img'); ?>" />
</div>
</div>
<!-- # ROW-2 # -->
<div class="row">
<div class="grid-item item-2">
<img src="<?php echo ot_get_option('left2_img'); ?>" />
</div>
<div class="grid-item item-1" >
<img src="<?php echo ot_get_option('center2_img'); ?>" />
</div>
<div class="grid-item item-3">
<img src="<?php echo ot_get_option('right2_img'); ?>" />
</div>
</div>
<!-- # ROW-3 # -->
<div class="row">
<div class="grid-item item-small">
<img src="<?php echo ot_get_option('left3_img'); ?>" />
</div>
<div class="grid-item item-medium" >
<img src="<?php echo ot_get_option('center3a_img'); ?>" />
</div>
<div class="grid-item item-small">
<img src="<?php echo ot_get_option('centerb_img'); ?>" />
</div>
<div class="grid-item item-2">
<img src="<?php echo ot_get_option('right3_img'); ?>" />
</div>
</div>
</div>
CODE CSS:
/* ---- grid ---- */
.item-1,.item-3{
width:40%;
}
.grid {
background: #DDD;
}
/* clear fix */
.grid:after {
content: '';
display: block;
clear: both;
}
/* ---- .grid-item ---- */
.item-small{
width: 20% !important;
}
.item-medium{
width: 34% !important;
}
.item-2{
width: 25% !important;
}
.grid-sizer,
.grid-item {
width: 37.333%;
}
.grid-item {
float: left;
}
.grid-item img {
display: block;
width: 100%;
}
I put an image to better understand what they want to do.
The images must have a resolution adjustable height depending on.
I tried to .grid-item img {height:316px;} but the low resolution images do not look good.
What they want is to always have a fixed height equal pictures and look good on all resolutions.
Do you think you can help me to find a solution please?
Thank you in advance!
Because there are several fixed images, you can put them in a single img. In this way you can adjust your image a priori.
Furthermore loading a single img is less expensive than loading several imgs (look on Google "css sprite")