Aman Singh
Aman Singh

Reputation: 753

Width is not working

Sorry for this silly question, but i stick because of this problem, the width of the anchor tag is not working, basically i want to increase the height of the anchor tag so the text written in it does not wrap

.filteredRestBody {
    background: none repeat scroll 0 0 white;
    border: 1px dotted #5bc0de;
    border-top-left-radius: 23px;
    box-shadow: 0 0 0 grey;
    height: auto;
    margin-left: -14%;
    padding: 0 0 47px 8px;
    position: relative;
    top: 30px;
    width: 115%;
}

.filterThumbnails {
    background-position: 2px -19px;
    background-repeat: repeat;
    border-top-left-radius: 10%;
    border-top-right-radius: 10%;
    height: 300px;
    margin-left: 4.3%;
    margin-top: 50px;
    width: 234px;
}

.restaurantThumbnailsTitle {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 1.6em;
    height: 95px;
    margin-left: -14px;
    position: relative;
    top: 44.7%;
    width: 114%;
}


.restaurantThumbnailsTitle > a {
    color: white;
    font-weight: bold;
}

.restaurantThumbnailsTitleText {
    font-size: 1em;
    font-weight: unset;
    left: 0;
    text-shadow: 1px 1px 0 red;
    top: 0;
    width: auto;
}
<div id="filteredRestBody" class="row filteredRestBody">
   <div id="row1" class="row">
       <div id="indianchilly" class="col-sm-4 filterThumbnails" style="background:url('images/yochinathumbbck.jpg')">
           <img src="images/bestoffers.png">
           <div id="discountNum">Discount 15%</div>
           <div class="ratingsContainer">
               <div id="restaurantThumbnailsTitle" class="restaurantThumbnailsTitle">
                   <a href="viewRestaurant.php?rest=yochina">Indian Chilly</a>
                   <p class="restaurantThumbnailsTitleText">chilled out chinese</p>
               </div>
           </div>
       </div>
   </div>
</div>

I have tried many things but only solution which i got by increasing the width of filterThumbnails which i do not want to increase, Please, anyone help me out

Thanks in advance

Upvotes: 1

Views: 107

Answers (3)

Oriol
Oriol

Reputation: 288680

See the spec:

'width'

  • Value: <length> | <percentage> | auto | inherit
  • Initial: auto
  • Applies to: all elements but non-replaced inline elements, table rows, and row groups
  • Inherited: no
  • Percentages: refer to width of containing block
  • Media: visual
  • Computed value: the percentage or 'auto' as specified or the absolute length

a elements are, by default, non-replaced inline elements. So width property doesn't apply.

Upvotes: 2

Shomz
Shomz

Reputation: 37711

Inline elements can't have altered width. You need to make that anchor a block, or inline-block, see here (gave it a green background so you can see how wide it is):

.filteredRestBody {
    background: none repeat scroll 0 0 white;
    border: 1px dotted #5bc0de;
    border-top-left-radius: 23px;
    box-shadow: 0 0 0 grey;
    height: auto;
    padding: 0 0 47px 8px;
    position: relative;
    top: 30px;
    width: 115%;
}

.filterThumbnails {
    background-position: 2px -19px;
    background-repeat: repeat;
    border-top-left-radius: 10%;
    border-top-right-radius: 10%;
    height: 300px;
    margin-left: 4.3%;
    margin-top: 50px;
    width: 234px;
}

.restaurantThumbnailsTitle {
    background: none repeat scroll 0 0 rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 1.6em;
    height: 95px;
    margin-left: -14px;
    position: relative;
    top: 44.7%;
    width: 114%;
  }

.restaurantThumbnailsTitle a {
  display: block;
  background-color: green;
}

.restaurantThumbnailsTitle a:hover { 
  background-color: white;
}
<div id="filteredRestBody" class="row filteredRestBody">
   <div id="row1" class="row">
       <div id="indianchilly" class="col-sm-4 filterThumbnails" style="background:url('images/yochinathumbbck.jpg')">
           <img src="images/bestoffers.png">
           <div id="discountNum">Discount 15%</div>
           <div class="ratingsContainer">
               <div id="restaurantThumbnailsTitle" class="restaurantThumbnailsTitle">
                   <a href="viewRestaurant.php?rest=yochina">Indian Chilly</a>
                   <p class="restaurantThumbnailsTitleText">chilled out chinese</p>
               </div>
           </div>
       </div>
   </div>
</div>

Upvotes: 0

Billy
Billy

Reputation: 2448

an a tag is inline so it's not affected by width or height, add display:inline-block; to it's css and you should then be able to adjust it.

Upvotes: 0

Related Questions