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.
Related
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
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.
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;
...
}
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;
I don't even know if I'm doing this correctly, but I thought I'd ask to get a better opinion. Basically what I've done is this: created an information/navigation bar that expands depending on tab clicked by the user. What I'm trying to add is the functionality to expand a certain tab and be forwarded to it (like what this link would do: <a href="#contactus">) based on a link earlier on the same page. I can't seem to do it. The tab that should be opened is contained within a <ul><li> list and is hidden. I'll include the code:
<div id="tab1">
<ul class="tablinks">
<li><span>Check-Out</span></li>
<li><a onClick="show('tab2')">Payment</a></li>
</ul>
<table>
<tr>
<td><img alt=Check-Out src="http://link.com/images/checkouticon.gif" width=48px height=45></td>
<td>
<p style="font-family: arial,helvetica,sans-serif; font-size: 12px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px">information</p>
</td>
</tr>
</table>
<div class="tabbase"></div>
</div>
<!-- tab 2 -->
<div id="tab2">
<ul class="tablinks">
<li><a onClick="show('tab1')">Check-Out</a></li>
<li><span>Payment</span></li>
</ul>
<table>
<tr>
<td vAlign=top align=left><img alt=Check-Out src="http://link.com/images/paypalicon.gif" width=48px height=45></td>
<td>
<p style="font-family: arial,helvetica,sans-serif; font-size: 12px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px">information</p>
</td>
</tr>
</table>
<div class="tabbase"></div>
</div>
This is the CSS that affects it:
#tab1, #tab2, #tab3, #tab4, #tab5, #tab6, #tab7 { font-family: trebuchet ms, Helvetica, sans-serif; height:550px;}
#tab1, #tab2, #tab3, #tab4, #tab5, #tab6, #tab7 {
width: 750px;
font-family: "trebuchet ms", tahoma, verdana, sans-serif;
font-size: 11px;
}
#tab2, #tab3, #tab4, #tab5, #tab6, #tab7 {
display: none;
}
ul.tablinks {
width: 600px;
margin: 20px 0px 0px 0px;
padding: 0px;
list-style: none;
height: 23px;
display: block;
cursor: pointer;
border-bottom: 0px solid #fff;
}
ul.tablinks li {
display: inline;
float: left;
margin: 0px 4px 0px 0px;
padding: 0px;
}
ul.tablinks li a, ul.tablinks li a:visited {
display: block;
width: 79px;
height: 23px;
line-height: 23px;
text-align: center;
text-decoration: none;
font-weight: normal;
font-size: 11px;
background: url(http://link.com/images/tabout3.gif);
color: #ffffff;
}
ul.tablinks li span {
display: block;
width: 79px;
height: 23px;
line-height: 23px;
text-align: center;
text-decoration:underline;
font-weight: normal;
font-size: 11px;
}
ul.tablinks li a:hover,
ul.tablinks li a.hover {
background: url(http://link.com/images/tabover.gif);
color: #000;
}
ul.tablinks li a:active{
text-decoration:underline;
}
div.tabbase {
display: block;
height: 3px;
line-height: 8px;
font-size: 0px;
}
div.tabbase {
background: url(http://link.com/images/boxbase3.gif);
}
And last but not least this is the code that is within a .php external file that affects the hidden aspect of the tabs:
function show(id)
{
checkseo()
if (err == "1"){return;}
hide()
if(ie5 || ns6){
//document.getElementById(id).style.display = "inline";
document.getElementById(id).style.display = "block";
}
}
function hide(){
if(ie5 || ns6){
document.getElementById('tab1').style.display = "none";
document.getElementById('tab2').style.display = "none";
document.getElementById('tab3').style.display = "none";
document.getElementById('tab4').style.display = "none";
document.getElementById('tab5').style.display = "none";
document.getElementById('tab6').style.display = "none";
document.getElementById('tab7').style.display = "none";
}
}
So the idea is to be able to insert a link earlier in the document to open the "Payment" tab. I tried something like this: Payment Information and changed the tags for the list to: <li><span name="payments">Payments</span></li>. This didn't work unless I had already clicked on the "Payments" tab and opened it and then clicked on the link. Then my screen would scroll down and focus on that area. Is there a way to have the screen scroll down and view the <span> without having to 'open' it first?
Thanks for all your help in advance. And I should note, that while I do have some ability with HTML, Javascript, and PHP, I'm still learning and don't know all of the best ways of doing things.
The best (and easiest) way to code this is to use a JS framework like jQuery. It'll help tremendously in normalizing the browser differences.
But if that's not an option, let's try to fix the existing code. Payment Information will jump to an element with the id="payments", not name. Once you fix that, add an onClick="show('tab2')" to that <a>.
In the show function, what is the point of this code if(ie5 || ns6)? This is basically saying, if it's IE5 or Netscape6, then show the element (assuming the variable ie5 and ns6 are set properly somewhere of course). Try removing this, I don't think you need it.