Whole div a clickable link [duplicate] - php

This question already has answers here:
Make a div into a link
(30 answers)
Closed 2 years ago.
I am trying to get my whole div a clickable link but I am not sure the correct way to do it. Would anyone be able to help me with this, it would be greatly appreciated. I am new to coding so I am still learning proper coding. Thanks.
.container {
display: flex;
margin: auto;
width: 1052px;
}
.container>div {
background-color: #ffffff;
border: 1px solid #aaaaaa;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
flex: 1;
/*grow*/
height: 210px;
margin: 45px 10px 0px 10px;
width: 231px;
}
.container img {
height: 140px;
width: 241px;
}
.container>div a {
color: #353748;
display: block;
font-family: Netflix Sans, Helvetica, Arial, sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 20px;
padding: 5px 10px 5px 10px;
text-decoration: none;
text-overflow: ellipsis;
text-transform: initial;
}
.container>div a:hover {
color: #353748;
display: block;
font-family: Netflix Sans, Helvetica, Arial, sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 20px;
padding: 5px 10px 5px 10px;
text-decoration: underline;
text-overflow: ellipsis;
text-transform: initial;
}
<div class="container">
<div>
<img src="https://capebretonstartpage.com/1/wire-31023566-1595346165-638_636x382.jpg">
About vAdd An Image Add An Image
</div>
<div>
<img src="https://capebretonstartpage.com/1/wire-31023566-1595346165-638_636x382.jpg">
About vAdd An Image Add An Image
</div>
<div>
<img src="https://capebretonstartpage.com/1/wire-31023566-1595346165-638_636x382.jpg">
About vAdd An Image Add An Image
</div>
</div>

You can put the div inside an <a> tag

Related

can't click anything on my website, in mobile view

Google keeps giving me results based on fixing my phone, but the problem is on my website. This is a weird problem, but on a mobile device on my website, I can't click any buttons or links. desktop works fine, but mobile is having issues. I'm making this site directly on cpanel, so I don't know if there is some special code I need to add to detect mobile taps, I usually use wordpress, so I don't know a whole lot about making a website directly on mysqli. The mobile taps will work outside a container, but I need it to work inside my page container. its inside a <div> and a <pre>. I don't really understand the problem, here is what some of my code looks like:
Global Styles:
pre{
border: solid 3px #2b333d;
border-radius: 10px;
font-size: 15px;
color: #3c3d3c;
margin: 1%;
padding: 10px;
background: #eaeaea;
display: block;
font-family: monospace;
white-space: pre-wrap;
}
input{
border: solid 2px #2b333d;
border-radius: 10px;
font-size: 15px;
color: #3c3d3c;
margin: 1%;
padding: 8px;
background: #f7f7f7;
font-family: Arial, Helvetica, sans-serif;
white-space: pre-wrap;
outline: none;
display: inline-block;
}
input[type=button], input[type=submit], input[type=reset]{
border: solid 2px #142135;
border-radius: 10px;
font-size: 18px;
color: #f7f7f7;
margin: 1%;
padding: 5px 7px;
background: #5791ed;
font-family: Arial, Helvetica, sans-serif;
white-space: pre-wrap;
outline: none;
letter-spacing: 0;
display: inline-block;
}
form{
line-height: 0.2;
white-space: normal;
}
Page/Header Styles:
.page_m{
background: #fcfcfc;
width: 99.9%;
left: 0.1%;
z-index: -20;
top: 30px;
position: relative;
}
.page_inner_m{
padding: 20px;
z-index: -20;
position: relative;
font-family: Arial, Helvetica, sans-serif;
white-space: pre-wrap;
color: #2d2d2d;
letter-spacing: 0.5;
line-height: 1.55;
border: 0;
border-radius: 0;
font-size: 18px;
margin: 0;
background: none;
display: block;
}
scripts:
<?php
?>
<style>
<?php include 'header.css'; ?>
</style>
<?php
echo '<div class="page_m">';
?>
<style>
<?phpinclude 'style_m.css';?>
</style>
<?php
echo '<pre class="page_inner_m">';
//header start
echo '<div class="menu_m">';
$host = $_SERVER['HTTP_HOST'];
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
$domain = "{$matches[0]}\n";
echo '<center class="title_m">'.$domain.'</center>';
echo '</div>';
//header end
echo '</pre></div>';
echo '</div>';
?>
Fixed it :D just needed to replace echo '<pre class="page_inner_m">'; with echo '<body class="page_inner_m">'; and replace echo '</pre></div>'; with echo '</body></div>';
I'll keep this up incase anyone else finds it helpful. switching the <pre> tag with a <body> tag solved the problem for me.

How to add space between menu elements (in wordpress)?

I am working in wordpress and I have this menu with 4 menu items.
The problem is that they are touching each other and there is 0
space between which makes it ugly in my opinion.
Now this problem only
occurs in wordpress. So I have to find a solution how to put some space between.
Maybe you guys know a solution without having to install something on WP.
(the codes in the body is exactly as in my wordpress to demonstrate how it looks like. You can enter it and that will put some space between, but unfortunately that doesn't work in wordpress.)
<style>
.smallmenu {
margin: 0 auto;
max-width: 436px;
width: 100%;
}
.Capital {
margin: 0px 0 -5px 0;
line-height: 63px;
font-size: 60px;
font-weight: ligter;
}
.smalltext {
text-align: center;
margin-top: 0px !important;
font-weight: 100px;
font-size: 14px;
}
.smalltextpub {
text-align: center;
margin-top: 0px !important;
font-weight: 100px;
font-size: 14px;
margin-left: -5px;
}
.cornermenu {
display: inline-block;
margin: auto;
border-radius: 25px;
background: #769DBD;
padding: 20px;
width: 100px;
height: 100px;
text-align: center;
color: #fff;
font-family: Arial;
padding-top: 10px;
text-decoration: none;
}
#hoverr:hover {
border-radius: 25px;
background: #464646;
padding: 20px;
width: 100px;
height: 100px;
text-align: center;
color: #fff;
font-family: Arial;
padding-top: 10px;
text-decoration: none;
}
* {
box-sizing: border-box;
}
</style>
<div class="smallmenu"><a id="hoverr" class="cornermenu" href="#methods"><span class="Capital">M</span>
<span class="smalltext">Methods</span></a><a id="hoverr" class="cornermenu" href="#background"><span class="Capital">B</span>
<span class="smalltextpub">Background</span></a><a id="hoverr" class="cornermenu" href="#results"><span class="Capital">R</span>
<span class="smalltext">Results</span></a><a id="hoverr" class="cornermenu" href="#publications"><span class="Capital">P</span>
<span class="smalltextpub">Publications</span></a></div>
Just set a fixed margin on .cornermenu.
Something like margin: 2px
JSFiddle link
.cornermenu {
...
margin: 2px;
...
}

Centering div in CSS (WP theme development and PHP)

I'm currently developing a wordpress theme with PHP, but my problem is with the css. I have tree divs, which i have inside a parent div. The parents div is by default 100%, so i want to specify the parent div (class: "single-general-sec1"). I've tried to calculate how wide the parent div should be in order for me to center it, but my calculations do not work. Please help.
Parent div should, by my calculation, be: 61% + 425px, but that dosen't work.
.single-general-sec1 {
margin-top: 150px;
margin-bottom: 150px;
height: auto;
width: calc(61% + 425px);
background-color: red;
}
.single-btype-div {
width: 250px;
display: inline-block;
float: left;
}
.single-gen-header {
font-size: 14px;
color: #D9D9D9;
font-family: "Roboto";
font-weight: 700;
text-transform: uppercase;
letter-spacing: 3px;
margin: 0;
width: auto;
}
.single-gen-desc {
color: #000;
font-family: "Roboto";
font-size: 28px;
font-weight: 300;
letter-spacing: 3px;
margin: 0;
width: auto;
margin-top: 5px;
}
.single-description-div {
width: 55%;
display: inline-block;
margin-left: 3%;
float: left;
}
.single-description-desc {
color: #000;
font-family: "Roboto";
font-size: 20px;
font-weight: 300;
letter-spacing: 1px;
margin: 0;
width: auto;
margin-top: 5px;
}
.single-live-button {
margin-top: 5px;
width: 175px;
height: 40px;
background-color: #8AA6B6;
border-radius: 8px;
border: none;
color: #fff;
font-size: 15px;
font-family: "Roboto";
font-weight: 300;
letter-spacing: 2px;
text-transform: uppercase;
}
.single-live-div {
width: 100px;
display: inline-block;
margin-left: 3%;
}
<div class="single-general-sec1">
<div class="single-btype-div">
<p class="single-gen-header"> - Typ av projekt </p>
<p class="single-gen-desc">
<?php the_field('project-type'); ?> </p>
</div>
<div class="single-description-div">
<p class="single-gen-header"> - Beskrivning </p>
<p class="single-description-desc">
<?php the_field('description'); ?> </p>
</div>
<div class="single-live-div">
<p class="single-gen-header"> - Se live </p>
<a href="<?php the_field('page-url') ?>"><button class="single-live-button">
Besök sida > </button></a>
</div>
</div>
You cannot center a div using % values for width. Also the calculation is wrong: 250px + 175px + 100px = 525px so, the parent div should be 525px in order to fit nested divs. But you should normalize HTML first. Or just use bootstrap.css.
Another thing. For center a div you can use display:inline-block then on his parent use text-align:center.
Or when you have a fixed width, margin:50px auto;

Previously i have added color: red to my code, however i have deleted it, but it still shows on my web

Previously i have added color red to my css code. However, i have deleted the code. But the red still remain on the web. What should i do? This is the html on my php file.
echo " <div class='toship-info'>
<div class='toship-header'>Deliver to: </div>
<div class='toship-content'>
<div class='toship-att'>Name : </div>
<div class='toship-data'>$ship_name</div>
<div class='toship-att'>Address : </div>
<div class='toship-data'>$ship_address</div>
<div class='toship-att'>Contact No : </div>
<div class='toship-data'>$ship_contact</div>
<div class='toship-att'>Email : </div>
<div class='toship-data'>$ship_email</div>
<br><strong>*If there is any inquiries please contact our Apex Store at
+6(04)-3901025. </strong></br>
</div>
</div>
";
This is my css file. How should i change it?
.toship-info{
width: 600px;
margin: auto;
}
.toship-header{
background: rgb(63,63,63);
color: white;
font-size: 14px;
font-weight: bold;
height: 24px;
line-height: 24px;
padding-left: 15px;
}
.toship-content{
background: rgb(238,238,238);
height: 130px;
padding-top: 10px;
}
.toship-att{
width: 100px;
text-align: left;
font-size: 12px;
font-weight: bold;
padding: 3px;
float: left;
box-sizing: border-box;
}
.toship-data{
width: 500px;
padding: 3px;
font-weight: bold;
font-size: 12px;
float: left;
box-sizing: border-box;
}
.toship-item{
width: 600px;
margin: auto;
margin-bottom: 20px;
}
.toship-item-header{
background: rgb(63,63,63);
color: white;
font-size: 14px;
font-weight: bold;
height: 24px;
line-height: 24px;
margin-bottom: 0px;
padding: 0;
margin: 0;
[![enter image description here][1]][1]}
Try to open in other browser, or if you are using any framework or cms then clear view cache.
Your browser probably cached the page. Try to clean your history/cache. How to do this depends on the browser you are using. For example, in Chrome you will go to History > History > Clear navigation data... > Image and files stored in cache. Also, as #rrd said in comments, in most browsers (Chrome included) Ctrl+R will reload the actual page and not the cached one.
Ctrl-F5 will do the trick. It's in the browser cache. Ctrl-F5 will ask for a complete new request and hence avoid the cache.
When i use the below code i don't see any red text
<style>
.toship-info {
width: 600px;
margin: auto;
}
.toship-header {
background: rgb(63, 63, 63);
color: white;
font-size: 14px;
font-weight: bold;
height: 24px;
line-height: 24px;
padding-left: 15px;
}
.toship-content {
background: rgb(238, 238, 238);
height: 130px;
padding-top: 10px;
}
.toship-att {
width: 100px;
text-align: left;
font-size: 12px;
font-weight: bold;
padding: 3px;
float: left;
box-sizing: border-box;
}
.toship-data {
width: 500px;
padding: 3px;
font-weight: bold;
font-size: 12px;
float: left;
box-sizing: border-box;
}
.toship-item {
width: 600px;
margin: auto;
margin-bottom: 20px;
}
.toship-item-header {
background: rgb(63, 63, 63);
color: white;
font-size: 14px;
font-weight: bold;
height: 24px;
line-height: 24px;
margin-bottom: 0px;
padding: 0;
margin: 0;
</style>
</head>
<body>
<div class='toship-info'> "
<div class='toship-header'>Deliver to: </div>
<div class='toship-content'>
<div class='toship-att'>Name : </div>
<div class='toship-data'>$ship_name</div>
<div class='toship-att'>Address : </div>
<div class='toship-data'>$ship_address</div>
<div class='toship-att'>Contact No : </div>
<div class='toship-data'>$ship_contact</div>
<div class='toship-att'>Email : </div>
<div class='toship-data'>$ship_email</div>
<br>
<strong>*If there is any inquiries please contact our Apex Store at
+6(04)-3901025. </strong>
<br />
</div>
</div>
</body>
Please make sure you markup your HTML properly..
was incorrectly marked up

Only show text on image when you hover - wordpress theme

I'm using this WP theme and I'm struggeling to adjust the code so that the Title and Description in the content boxes only show on hover (at the moment they're always displayed and hover just makes the image go darker).
Here are the codes in question (as far as I can tell):
.home_featured_post_last { margin-right: 0; }
.home_featured_post_hover { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; text-decoration: none; border-radius: 5px; }
.home_featured_post_hover:hover { background: url('images/trans-back.png') repeat; text-decoration: none; border-radius: 5px; }
.home_featured_post_tbl { display: table; width: 100%; height: 100%; }
.home_featured_post_tbl_cell { display: block; text-align: center; vertical-align: middle; color: #fff; text-shadow: 1px 1px #000; font-size: 14px; font-family: Arial, Helvetica, sans-serif; color: #fff; letter-spacing: 1.5px; font-weight: 400; }
.home_featured_post_tbl_cell h3 { text-shadow: 1px 1px #000; font-size: 19px; font-family: Arial, Helvetica, sans-serif; color: #fff; letter-spacing: 1.5px; font-weight: 700; }
<a class="home_featured_post_hover" href="<?php the_permalink(); ?>">
<div class="home_featured_post_tbl">
<div class="home_featured_post_tbl_cell">
<h3><?php the_title(); ?></h3>
<p><?php echo ds_get_excerpt('40'); ?></p>
</div><!--//home_featured_post_tbl_cell-->
</div><!--//home_featured_post_tbl-->
</a><!--//home_featured_post_hover-->
As suggested in some other posts, I've tried adding visibility: hidden; and visibility: visbile; to the CSS in various different combinations but either it just hides the text completely or it doesn't work at all. Does this have to do with how the PHP code is formated? Any thoughts on how to do this?
Sorry if this is really obvious - I can't work it out.
Try adding these CSS lines... if you want a smoother effect, you can add the css transition property!
a.home_featured_post_hover .home_featured_post_tbl_cell { opacity:0; }
a.home_featured_post_hover:hover .home_featured_post_tbl_cell { opacity:1; }
What this does is basically make the title/desc div transparent, then show it when the mouse is over the link.

Categories